Immunity? No. Cops are not immune from prosecution for perjury. LEOs and prosecutors cannot knowingly lie in court. Prosecutors are not even allowed to put someone on the witness stand if they know that person is going to lie.
Cops can lie to a person to extract a confession, e.g. "We have your DNA, we know it's you." This is during the course of an investigation, and there's no law against it, just like lying is not a crime generally. (Lying to the police is, however, a crime in most jurisdictions, but remaining silent is not. Which is why no one should ever talk to the police.) But in court, where they swear to tell the truth, they cannot lie without committing a felony. No exceptions. They cannot lie to a court even if they are "undercover."