From my (probationary) Constitutional Powers Guy (The field of applicants is very crowded):

Please consider this my audition as your “Constitutional Powers Guy:” [Consider me your own personal OLC] My basis is not only practice in constitutional law, federal criminal prosecution and separation of powers, but also as a current and going on 26 + yrs as an Army Reserve officer—
1. All US military officers take an oath – to preserve protect and defend the US Constitution. The oath is not to the Commander in Chief (nor the personal loyalty oath to any Leader as historically occurred with certain central European armies featured in LF). So no military officer or soldier is bound to obey an unconstitutional (hence illegal) order. This is one of the inherent checks or limits on executive branch power.
2. The Secretary of Defense is subject to the same oath on confirmation and assuming office. He serves at the pleasure of the President, but he too must disobey or resist any unconstitutional order. So he resigns or is fired.
3. Same generally applies to all officers of the Executive branch – they are not supposed to follow unconstitutional orders or otherwise resign.
4. When the inaction or refusal of the executive branch officers is insufficient, and we have stipulated there is no time to seek Congressional action (like impeachment), can we turn to the judiciary, i.e. SCOTUS? Not unless SCOTUS has jurisdiction. And by that I mean, Article III of the US Constitution requires that SCOTUS may only hear actual cases or controversies – that is, somebody has to file a suit or a petition to get SCOTUS to act, and SCOTUS has to decide they have the authority and the jurisdiction over both the subject dispute, and the parties to that dispute… but SCOTUS also cannot hear original jurisdiction cases (that is, be the first court to take a crack at the dispute) unless it is the narrow class of disputes directly between States; it will have to go through federal district (trial) courts and the courts of appeals (usually the DC circuit) first –and who will have standing to bring that complaint? Perhaps the officer who gets fired or is forced to resign for disobeying POTUS, or the direct victim of the illegal and unconstitutional act of POTUS.
5. Once SCOTUS (or a lower federal court) had taken the case, satisfied itself that the parties have standing, that the POTUS has acted in violation of the law or constitution, and ordered compliance with the court’s order – then, if POTUS still resists or disobeys the court order, the court might order enforcement – but it usually orders the other branches (like DOJ and law enforcement agencies) to give effect to its orders. Or SCOTUS can send its own Marshal to enforce its order. Last time that was tried, CJ Taney sent a marshal to release secessionist John Merryman from prison during the Civil War in Maryland – and Pres. Lincoln and his Army General declined to let the marshal into the fort, where Merryman was being held in violation of a SCOTUS order for habeas corpus.
6. Could SCOTUS order the Army to act? Maybe. But most likely only if the Army was considered a party in question or had been ordered itself to do what POTUS had commanded and was in issue in the dispute.
7. More likely answer or result: If there is sufficient urgency and credibility to the opposition, the Vice President and a majority of the cabinet officers under the 25th Amendment, sec.4 of the Constitution would have to decide that the POTUS was no longer competent or able to perform the duties of his office (given his blatant disregard or opposition to the Constitution and its processes), and then communicate that fact to the Congress (president pro tempore of Senate and Speaker of the House) and declare the VP as Acting President. Kinda like an episode of The West Wing once showed. The Congress could get involved to impeach or not; and if the POTUS under Amend 25 sent his own message to Congress that he was in fact capable of exercising the office and assuming the powers once again, the 25th Amendment requires the Congress to decide by two-thirds vote of both houses whether to restore the former POTUS or keep the VP-Acting POTUS. If the former POTUS refuses an adverse decision, we then would have an actual case or controversy for the SCOTUS to decide.. and if it decides the former POTUS must go, perhaps then it could order the Army to remove him, tho more likely a DoD officer who followed the Congressional resolution or SCOTUS ruling would act before then to remove the discarded chief executive.
Please forgive excess factual detail or prolixity. Hope it helps. As I am only expressing my personal opinions and not that of DOJ or the USG, please withhold my name if you choose to repeat and publish..
Thanks,