I would imagine that you would have to consult the law of the country that you are in and not religious backward "laws" that don't actually mean anything.
agave me a thumbs down. I bet it was a Jew. How will I sleep tonight.
two thumbs now!! I'm devastated. The truth hurts I guess.
No. Judaism does not believe in the end justifying the means. According to Jewish law you must give your life prior to killing someone. Murder, Idol Worship and Torah-forbidden sexual relations are the three sins one must first give their life for before committing. If someone tells you to kill one person or they will kill an entire community, you must allow the entire community to be killed before you yourself kill one innocent person. Even bad guys must first be tried before a Jewish court (Sanhendrin).
Jews live by the laws of the country where they live. Is it permissible in your country for your undercover police to kill someone to protect identity? No? Well, there's your answer.
The question is not as simple as it seems- their are multiple issues involved that could allow or disallow the person form acting.
An example that would be allowed: The bad guy is a convicted criminal that escaped from death row- since the courts have ruled that he is guilty, the undercover cop could act on their behalf to kill him.
Outside of this extreme case there are not many scenarios when it would be allowed- another case where it would be allowed is if the bad guy were threatening other people- making this killing legitimate under the law that allows a person to kill a roded (pursuer) that is about to kill someone else.
Where it starts getting murky is in the realm of fact that soldiers/police in Judaism have a right to kill in defense of the nation/civilian population. Normally they act within a framework that makes it very clear when they can and cannot act. An undercover police officer operates in this Grey area of when does the threat to their lives mean not acting to kill the bad guy allows more innocents to suffer? In the modern era, this Grey area and license to act/not act is generally defined by the state and the undercover officer knows the laws relating to his own country. Thus under the principal of "Dinei Malchycharcha" "The laws of the land are your laws" i.e. where the law of the land does not require us to break Jewish law we have to follow it, in the modern era an undercover police officer could act as mandated by the country's law without violating Jewish law.
As an aside- we see historically where "Dinei malchutcha dinchah" has not been aplied, such as with the Roman edicts to stop Torah study, circumcision and Shabbos observance, or the Seleucid order to place a statue of Zeus that led to the Maccabean revolt; the Conversos that were only pretended to convert to avoid being sent into exile and so on.