Hilchos Lashon Hara chapter 4, section 5
But if he sees that the sin was committed by a person who is among those foolish people who are scoffers and cynics, people who hate rebuke, as Shelomo Hamelech teaches in Mishle: “Don’t try to rebuke a scoffer because he might come to hate you”, and most assuredly he would not accept rebuke, and can repeat his sin again. Therefore, it would be appropriate to disclose his action to the authorities of the city who would then chastise him because of his sin and prevent him from committing the sin in the future. It also would be appropriate to disclose his actions to the relatives of the sinner since they can influence on him. Note the sole motivation of the one who is reporting this person’s actions must be for the sake of Heaven, and not for the hatred of the sinner. Also, the judicial authorities must chastise this person discretely and not shame him publicly.