Shemiras Halashon Halachos

Hilchos Lashon Hara, chapter 1, section 7

If one is sitting with a group of people saying forbidden things and cannot leave their company, and when he sits and keeps silence he seems like a madman to them, nonetheless, it is certainly forbidden to speak forbidden things with them, and regarding this Chazal say (Eideyos 5:6), "Better for a person to be called a madman his whole life, that to be called a wicked person for one hour before the Omnipresent." He should arouse himself at such a time with all his strength to control himself, and he should be confident that for this he will receive fitting reward from heaven, as reward is according to the trouble involved. The more trouble one has to observe a mitzvah, so one receives more reward. To this applies the statement of Chazal, "Every moment that a person shuts his mouth, he merits the hidden light that no angel or creature can conceive of."

Hilchos Lashon Hara, chapter 1, section 8, 9

The prohibition of lashon hara applies whether one actually speaks of the person with one's mouth, or writes it in a letter. Also, it makes no difference if one says the lashon hara explicitly, or if one relates through a hint. All these cases are lashon hara. Know also, that even if one denigrates oneself while denigrating one's fellow, it is still considered lashon hara.