This question is not specific to any particular movie or a TV show. Although it came to my mind when I was recently watching a particular episode of Sneaky Pete. It's a great show by the way.
The girl asks a cop (who was a corrupt one) whether he was a cop. He was definitely reluctant while answering it but indeed answered "Yes". Details of the scene aren't important here.
In many movies and TV shows I have observed similar dialogues. Most common ones are where a prostitute is being inquired/questioned by someone and she asks the questioner "Are you a cop?" and quite often the questioner answers with the truth (yes or no).
How close is this to reality in US? Does the cop always have to answer with a yes?
P.S. People who might feel like downvoting/closing this one I request you to go through the tag realism first.