Bismihi ta'ala
This must be done by the decision of a vet or a professional, which means someone qualified should be consulted and should deal with it. Also, whatever is done should be done in a humane way, with a correct procedure and within legal perimeters.
Otherwise, it could be haram.
And Allah knows best.