It is ethical to disobey an unethical law.
And sometimes it is ethically required to disobey an unethical law. Sometimes courage has a cost.
Don't just not comply in advance. Consider not complying period. Again, sometimes that is the ONLY ethical choice.