If you work for someone else and carry out your tasks as instructed, and have tried to bring up the absurdity of it all as specced but they insist you do it anyway then I don’t see what would be unethical about it? Only talking about brain dead/useless endeavors, not bad/evil projects.