Sort of like a soldier following/not following orders he knows to be illegal?
Yes. A person has no ethical duty to obey an immoral rule. Therefore one who refuses to follow said rule (even without open disagreement) is not untrustworthy or dishonest IMO. However, if caught then one must accept the consequences even if the rule was wrong. Another way of putting it is that an immoral rule is ethically invisible to an honest person.
"God and the Soldier we adore, in time of trouble but not before. When the danger's past and the wrong been righted, God is forgotten and the Soldier slighted."