Morally
Morally, you wanted to work more for earning more. That is nothing morally bad. Except if we substitute "justice" and "moral" with the written characters of the law.
Legal, with the University
Your case with the University and with France are independent from each other. Very likely, France does not even know it. The University does not need to pass this information to the state.
About your case with the University: very likely, you have two different contracts with them. First, you have a work contract with the University, this work contract must close out sidework. If it does not, or it closes out badly (lawyers!!!), they can not fire you on this reason. You also have a student contract (or what is its name). They might fire you from the job, but not from the doctoral school.
You must talk with a lawyer because chances are high that you can save things.
Universities often fear suing them and they will rather allow it.
You stay clearly under a very strong psychological pressure. You must find a lawyer with whom you can talk about your options.
Most importantly, you (as you have written in your now closed post) did not commit really serious.
Legal, with the country
Here you again need a lawyer. Most importantly, because also your employer employed you illegally, and that is his responsibility. Your employer do not want it.
If there would be a court case (99% it won't happen), you could say, the employer said everything is okay. And the court will make the employer responsible, because he needed to know the work law in details, and not you. On this reason, primary interest of the employer is that no trace must remain about your whole work for him.
Fact that the work happened in another country, makes likely that your visa requirements were not violated.
Most likely outcome
The University will probably bow before a legal threat, but they will purge you out anyways.
You will be a temporary resident in the EU with a broken Phd program. That is nothing bad. Here is the time to find your first job here, this time a legal one. You will need to visit some government offices for a work permit as skilled emmigrant.
Believe me, guys without papers et all can do that. And you are a postgrad.
In practice, there is no way to expel you from the EU by force (beside many others: you can just go to Germany and restart this whole thing - there are 35 countries here).
While you are looking for your jobs, you will only show in your CV an entry as "doctoral program, X. University" and so. If they ask, then you answer that you could not end the program because anything. No one will call the University to find this dark spot. Even if anyone would try, they could not even find your former teachers. Anyways, if the University would say anything, you could sue them for defamation and they do not want to risk it.
Best possible outcome
Lawyers will talk and they make a consensus of that they keep this whole thing inside the University. The University makes an internal process where you get some... punishment, for example half year suspension of similar. If you are a high performer, you will get your Phd. If it would happen, you will need to watch your steps until you get the Phd, odds will be that not everyone will like you in the future.
About your University
Clearly you have a very toxic atmosphere. No sane University and no sane workplace does it on this way. You had a serious problem, they find a solution, that would be the ordinary attitude. This "resign or we fire you", and that even your bosses etc are in threat, this is totally abnormal. They consider you an "offender" for doing a summer work, this is a totally non-sense over-aggregation of the reality.
Legal help
Find lawyers! They are not very cheap in the EU. If you can not afford it, find legal helpers everywhere you can. Most importantly, you are in threat of expelling from the EU for doing nothing really bad, that is clearly a case of something might try to help you.