Software is a double edged sword.
Is there a way to add a clause to encourage ethical use or a licence that exists in this respect?
My concerns are in terms of avoiding harm to someone.
Open Source Stack Exchange is a question and answer site for people organizing, marketing or licensing open source development projects. It only takes a minute to sign up.Sign up to join this community
No - because then it wouldn't be open source.
The Open Source Initiative defines one of its essential freedoms as:
6. No Discrimination Against Fields of Endeavor
The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.
The Free Software Foundation also requires a similar freedom in any license it considers to be open source:
The freedom to run the program as you wish, for any purpose (freedom 0).
This essentially means you cannot restrict how someone will use your program, including their ethics or morals for doing so. If you do, you wouldn't be able to use an open source license.
Richard Stallman has written an article on this exact subject where he concludes that:
The result would be a system that you could not count on for any purpose. For each task you wish to do, you'd have to check lots of licenses to see which parts of your system are off limits for that task.
There's also a great answer over at Programmers.SE which goes into this in more detail.
In the end, to require your users to "avoid harming someone" could - depending on how you legally word it - be extremely broad and open to wide interpretation. For example, does this refer to physical harm only, or emotional harm too? What about harm through loss of sales if the program successfully competes against a proprietary product?
Depending on what your software is, governments might want to use it too. Would policies that do end up causing - even unintended - harm to people therefore mean the use of the software to design, develop or write the policy was against the license?
As you can see, it inevitably comes down to the fact that everyone is going to have a different opinion, and with restrictions on what software can or can't be used for it would unfortunately make open source software not very open at all.