Sorry, but no one has to follow unethical orders - and this is one of them.
Actually a lot of things that officers and soldiers do under orders are unethical -- spying on people, trespassing on private property, shooting people, dropping bombs on people, etc. Part of the reason there is a chain of command is because soldiers often have to do things that an ordinary person would be ethically opposed to doing voluntarily. It's illegal orders that one is obligated to disobey. You can't order a subordinate to commit a crime. But any lawful order must be obeyed, even if the person given the order disagrees with it.
And Federation law as it pertains to artificial life forms is still evolving. According to A Time to Be Born, Ch. 17 (p. 276 of the paperback edition), Admiral Nakamura was able to use the loophole that since Data's chip was added after he joined Starfleet, it could be considered add-on equipment, and regulations gave Starfleet the right to determine what equipment an officer used while on duty. Without any specific laws or regulations to the contrary, Nakamura's order, however unethical, was still lawful and thus had to be obeyed.
Now, one could question why the characters didn't mount a legal challenge as they did in "The Measure of a Man." But we need to keep in mind that what's at issue here is Data's right to choose. The legal challenge in TMoaM only happened because Data chose to resign rather than obey orders. It wasn't something Picard or Geordi made him do; it would be pretty hypocritical to fight for his right to choose by denying it to him. He chose to resign rather than submit to Maddox's experiment, and Maddox then issued a legal challenge to force Data to obey, leading to the hearing that determined Data's right to choose. But in this case, conversely, Data chose to obey Nakamura's order rather than fighting it. Why did he make the choice differently this time? Well, my story "Friends With the Sparrows" in The Sky's the Limit might help explain that. It shows Data learning that he doesn't need to depend on the chip to define him as a person, that he is who he is regardless of his emotional state. I wrote the story to justify why the later movies showed the chip becoming less and less a part of his life despite Generations treating it as a life-changing thing.