While I wasn't covered by the UCMJ I once had a similar situation.
I was employed at an Army depot and under same restriction of what happens if ya disobey a direct order from a superior. I was a civilian employee of the Army.
I immediate supervisor who worked directly for the depot commander a bird colonel told me to work some of my folks overtime BUT only if I had proper funding to cover it. I did not have that funding in my budget.
He left on leave and went home for the day. That left another division chief at the same level in the organization in charge for the afternoon.
That acting director called me and gave me a direct order to work my people and to charge it to an illegal funding code. I was in supply and he ordered me to use maintenance money. That legally constitutes theft of funds.
I told him I could not legally do that. He made it a direct order and since he had been appointed acting director for the afternoon he was in effect my direct supervisor that afternoon.
So I called the person in charge of maintenance funding and asked her if she had funds that were for both maintenance and supply and she said no. She then asked me what was I gonna do report it to the commander. I told her I wasn't sure but yeah I thought I might.
I then called the depot lawyers and asked what to do given that I had been given a direct order to do something illegal. He directed me to write a memo to the acting director, telling him that what he had directed me to do was illegal and that I had to assume he was aware of something I was not aware of that made it legal and that therefore I was going to do it as directed but under strong protest. He said it was my only option to avoid being fired or prosecuted.
Before my secretary even got the memo typed I got a phone call with another order. Report immediately to the director's office. I explained the memo and that it was not yet typed. I was told to get to the director's office with no hesitation. I complied.
Once there the acting director was on the phone with the director of maintenance, their funding lady, the depot colonel and who knows who else but I think the depot lawyer was also on the line. I was told to sit down and wait.
A few minutes later my actual supervisor the director of quality assurance walked in and went into his office. He joined the phone call. That call lasted another 15-20 minutes. After it my real supervisor walked out and told me to NOT work my folks overtime unless I had correct supply funds to do so which he knew I did not. So I did not work my folks overtime that day.
I sure got a lot of folks' attention that day and kept my job and me and my actual supervisor were still fine afterward. The other division chief who had never been anything but an enemy and competitor for the director job should it come open again still hated me and was still looking for a chance to get me fired. He never pulled that trick off.
Police Chiefs are appointed, with politics usually involved, and Sheriffs are elected, politics always involved.
I've had both Police Chiefs, and Sheriffs order me to do unlawful things. "I ALWAYS" refused.
Were there consequences? About 30% of the time.
All they could do was fire me, and then justification would be the object of scrutiny.
I've butted heads with lieutenants, captains, assistant chiefs, and county attorneys. Hard feelings? About 80% of the time.
Your decisions are, or should be, made on what is right, and what is legal.