I wonder how would that work when you are working for companies like Lockheed Martin, knowing your code will be used in weapon that may kill innocent people.
Presumably similar to how it works for the professional Mechanical Engineers and Electrical Engineers they already employ. Ethics are subjective and nuanced. Ethics are also different from morals. Some people can live with the moral quandary that their work may do harm to innocent people and still have the ethical belief that they are doing the right thing generally and that their work does more good than harm. (I'm not one of those people myself with regards to the military-industrial complex, but I respect my friends that are have sat with their morals and weighed them into the ethical frameworks of how they do their jobs and what they feel about doing their jobs ethically.)
It's easy, you just tell yourself that all of them are the enemy. As long as you outsource your morality and thinking to the Department of State, you can sleep easy.
For a little bit I worried about that, wondered whether I would be morally comfortable working on that technology. Then Russia invaded Ukraine and I snapped back to reality. The consequences of even vaguely good actors not having missiles are worse than the consequences of those actors having missiles. Because you better believe Putin and his ilk are going to have them.