The Shulchan Aruch (EH 5:12) permits chemical castration of female animals but not of males
A person who gives a cup of root drink to a person or any living thing
in order to render him impotent, this is forbidden. But, he (the giver
of the drink) is not lashed. However, for a woman it is permitted to
drink this root drink in order that she become impotent so she cannot
give birth.
At the time, a potion was the way to chemically castrate, today there are more modern methods (e.g., zeutering, see here for details and a halachic analysis). Permitted methods for Jews would also be permitted for non-Jews.
Finally, I note there are workarounds available (see e.g., here) based on the Rema in 5:14.