CITE Sefer Chofetz Chaim chapter 4 halacha 8

If a person refuses to listen to a Jewish court verdict to do a mitzvah or to stop doing a sin the court has a right to publicize the matter and record it in official records for future future generations to see as long as the court assess he is just making up excuses of why he refuses to follow the verdict. But if the court is unsure whether he has a plausible excuse or. It then they shouldn’t publicize his refusal to listen to them.

Similarly we find in the Gemara Yoma 38a in the Mishna there, “And these are mentioned for censure: Those of the House of Garmu did not want to teach others the proper production of the Showbread. Those of the House of Avtinas did not want to teach others the proper means of production for the incense. Hugras , a Levite, knew a special musical method but did not want to teach it. Ben Kamtzar did not want to teach his special method of writing. Concerning the first ones mentioned in the previous Mishna on 37a it is said “The mention of a righteous one is for blessing,” and concerning these it is said, at the end of the verse, “And the name of the wicked will rot” (Mishlei 10:7).  The sages in that generation had warned them that they should share their secret talents with others to be sure they would not be lost but they refused to listen without any good excuse therefore the Mishna writes they are cursed, all the more people who refuse to listen to the courts to actually fulfill mitzvos or to not listen can be publicized for their wrong doing and written in the records.

However when the Rishonim say we are not allowed to speak lashon hara about people who don’t fulfill mitzvos or who sin even if it is true that is in two possible scenarios:

 A. Either he didn’t realize how severe of a problem it is to do the sin he did or to not fulfill the mitzvah he ignored, or

 B. Even if they understand the consequences sometimes the evil inclination gets the better of them and convinces people to transgress the word of G-D but afterwards most likely they regret what they have done and repent, therefore one may not speak any lashon hara about them. But people who have been warned to not repeat a transgression especially if warned by the court has no excuse that they don’t understand what they are doing wrong and if they refuse to change then it’s obviously not just the evil inclination overcoming his will to do good in the moment therefore it is permissible to speak out against him to be sure people stay away from him and not learn from his wrongdoings.