The mishna in Sanhedrin 6:2 explains how, when the condemned is being led out to be executed, they urge him to confess so he can have a portion in the world to come. This mishna ends:
רַבִּי יְהוּדָה אוֹמֵר, אִם הָיָה יוֹדֵעַ שֶׁהוּא מְזֻמָּם, אוֹמֵר תְּהֵא מִיתָתִי כַּפָּרָה עַל כָּל עֲוֹנוֹתַי חוּץ מֵעָוֹן זֶה. אָמְרוּ לוֹ, אִם כֵּן, יְהוּ כָל אָדָם אוֹמְרִים כָּךְ כְּדֵי לְנַקּוֹת אֶת עַצְמָן:
Rabbi Judah said: “If he knows that he is a victim of false evidence, he can say: may my death be an expiation for all my sins but this.” They [the sages] said to him: “If so, everyone will speak likewise in order to clear himself.”
The sages object because it will look like he's clearing himself, but so what? His confession, in whatever form, is so that God will judge him favorably, and God of course knows whether he speaks truly.
The g'mara's response is unsatisfying; it says that they object so that the condemned cannot bring discredit upon the court and witnesses. But hasn't the condemned been proclaiming his innocence all along? 5:4 says that he can argue for his acquittal during the trial, and 6:1 says that when they lead him out and call for people who can speak in his defense, he himself is allowed to. If the people hearing his confession didn't believe him during the trial, why would they suddenly believe him now? How does somebody saying "I didn't do it" all the way to the end discredit the court that convicted him, given that his saying it before the verdict apparently didn't discredit anyone?