It’s generally called a “duty to disobey,” and is empowered by the Uniform Code of Military Justice. The UCMJ is more concerned about the need to obey orders, but specifies the conditions when military personnel may feel justified in not following them:
If the order is “contrary to the constitution” or “the laws of the United States.”
If the order is “patently illegal, … such as one that directs the commission of a crime.”
https://www.findlaw.com/legalblogs/law-and-life/what-is-a-military-duty-to-disobey/
It could be, I don’t know either.