Many wars are simply what you’d expect from violent leaders who realize they can order other people into combat for them. But some wars really are for the greater good. There are definitely militaries that I want to see win, and militaries that I want to see lose.
I realize I don’t have any code that would be of any use to any military. If I did, I don’t see how I could write a license to allow the use of my code by only people I agree with.
You can write whatever you want in a license, including something as vague as “you can only use this code if I agree with your moral stances”. (For expediency, it might be worth enumerating the cases.)
The OSI might disapprove, but you don’t have to listen to them.