And an ethical engineer would design those weapons so that they don't blow up in a soldier's magazine or a submarine missile tube.
It's about adhering to a code of ethics, not undertaking some Hippocratic oath. In most places that code is actually a concrete document, which can be used as grounds to discipline/prosecute/regulate you, should you breach it.
I'm not pulling this stuff out of my ass, and I'm not sure why people seem to want to discredit my thesis that engineers are/should be ethically bound to not endanger the public good.
You do what you think is right. If you think designing weapons helps the greater good, you should design them well. Remember nuclear weapons prevented at least one global war and a couple regional ones.
And no. I have refused to design weapons early on in my career and I would refuse to do so now. I took my oath (a slightly different one, because I am Brazilian) and I take it very seriously.
Many wars of the late 20th century were proxy wars between nuclear powers. My bet is that, without MAD, they would have happened anyway, with the powers fighting directly. It would be very ugly.
Besides, we may need nukes to vaporize incoming asteroids. They can also be handy if you need to quickly dig a hole, move a mountain or if you need a cannon that can reach orbiting spacecraft.