What is a "license"?
The answer: A "license" is the permission given by the author of a software (or other kind of copyright protected work) to do something with the software that requires the permission of the author according to the law.
If the law states that something is allowed or forbidden independently of the permission of the author, the license terms do not have any effect:
In a country where the law forbids the distribution of certain software, it does not matter that the GPL states that distribution is allowed: It's forbidden by the law, so a "license" cannot allow it.
On the other hand, in a country where the law allows using foreign source code in closed-source programs without the author's permission, it does not matter that the GPL forbids this: It's allowed by law, so a "license" cannot forbid it.
The same is true for the (L)GPL and for the MS EULA.
Your actual question
... some of its parts are illegal in some countries ...
If this is the only reason why you want to forbid using the software in some countries, this is no reason to forbid the use in those countries in the license:
As I wrote above, it does not matter what the license says if the law forbids using the program.
You may publish your program under (L)GPL and point out that the use or distribution of your program may be illegal according to the laws of certain countries.