Hilchos Lashon Hara chapter 10, section 17

Someone did a misdeed and Reuven asked Shimon: Who did it? Even if Shimon realizes that Reuven suspects him of doing the misdeed, even if he witnessed the deed himself, he should answer: I did not do it [and not indentify who did it]. (Unless it is a transgression between man and his fellow in accordance with the rules outlined earlier in this chapter are followed, or something between man and G-d and in accordance with chapter 4 paragraphs 5,7, and 8). All that we have written is according to the strict law. However, a pious person should go beyond the letter of the law and not deny that he did it if the person who asked him can find out the real perpetrator who will then be ashamed. We find even more in Sanhedrin (11a) that many tanna’im took blame upon themselves so the offender should not become known. Similar, the Sefer Chassidim (22) writes: “If one is with a group of people and an unidentified member of the group did something wrong one should say, ‘I did the wrong, even though he did not. etc.”
The first part of the sefer Chofetz Chayim is completed.