The reason for this question is because many shipping companies now hire private security teams to travel along with them on their commercial shipping journeys. The answer to this question is yes and no. If a ship is approached by pirates thought to be an immediate danger to human life or the lives of others, then, yes, the use of deadly force is justified.
Otherwise, it is not okay for private security guards to kill pirates. Basically in today’s society the treatment of pirates is governed by human rights laws. Pirates are considered citizens and are subject to the laws governing citizens. Pirates committing crimes are not treated as military criminals.