You are not required to obey an unlawful order.
You are required to disobey an unlawful order.
You swore an oath to support and defend the Constitution of the United States against all enemies, foreign and domestic.
Read the whole thing.
This is based on current law, and the law could change. It would only be a moderate surprise if that rule about unlawful orders were repealed or changed out of all recognition.
Civil disobedience requires that you break the law in public and accept punishment. To my mind, this is a tactic, not a moral requirement. People who ran the Underground Railroad broke the law in secret, and I gather that some of them never talked about it. It may have been that they didn't want to be treated as heroes. It may have been that they didn't want to be treated as criminals. It may have been they wanted to keep their options open in case they saw a need to do such things again.
Standing up and being counted in opposition to atrocity is good. So is doing something sneaky to slow down or limit atrocity.
There are sound reasons for being at least fair-to-middling law abiding especially if you live in a society that doesn't have an extremely awful government, but ultimately, all you've got is your conscience and your judgement.