How would it be illegal?
Doctors are often required to attest their ethics before doing a job.
Doctors are often required to attest their ethics before doing a job.
Maybe the difference is that (computer-based) engineers are expected to do unethical work in some situations and for some employers, and there is an unwritten code that they can pass the buck and won't be penalised just for "doing their jobs".