Similar past (unsuccessful) discussion: https://news.ycombinator.com/item?id=13250450
By the way, I do not wish to turn this question into a political flame war. I also don’t think it’s unprecedented: some of the more popular licenses in use today are specifically intended as political wedges (GPL). And see also the JSON “use for good, not for evil” license.
On a more personal note, I’d like to use a similar license that prohibits military or military-adjacent use.
Enforcing it would be a challenge.
Wouldn't this party also control the courts? How would you enforce such a license, in an environment like that?
You can tweak a existing license to fit your goals. The issue is if it is not widely adopted then it will be a largely uphill battle to enforce said license, and the longer a legal fight the costlier it becomes.
To answer your question: certain software prohibits use for "military technology" which is one of the vaguest term iv seen. You also have license's that prohibit use in a commercial setting etc.
As for a license that prohibits certain users, that's more complex. The WordPress drama which had a button added blocking a specific group did happen, but a judge blocked that action. You probably need any "click to confirm you are not X or don't support Y at the very beginning of the release and not as an add in later down the road.
The easiest method for blocking certain groups of people would be a web developer banning any country IP that supports GDPR, and includes in the terms of service that you will not use the software if you fall into XYZ category.