Hafetz Haim Halachot
Halacha 73 / 215

Hilchos Lashon Hara chapter 4, section 5

If a person sees that the sinner is one of the "scoffers" who hate being rebuked – as the verse says, "Do not rebuke a scoffer, lest he hate you" – then rebuke will surely not be accepted, and the sinner may sin again.

In that case, it is good to tell the judges of the town, so they can discipline the sinner for the sin and keep them away from it in the future. Or one may tell the sinner's relatives, who can also influence them.

But the person telling must do it only for the sake of Heaven, and not out of hatred for the sinner. And the judges, too, should rebuke the sinner quietly and not shame them in public.