This is a problem that the courts face. What a person says in a court proceeding is regarded as protected from actions for defamation. In the trial the defendant can anything untrue in his own defence, however defamatory, if it is material.The same goes for what he says in mitigation on conviction.
The remedy lies with the court itself. The judge will say that he does not accept assertions of a scandalous or defamatory nature about some named individual and will say, in sentencing,that it he does not accept them, and is very likely to. go further saying something like 'You have made certain claims about X , which I do not repeat, in a desperate attempt to mitigate the sentence.I reject those claims. as unsupported and false.They do you no credit'
The press should quote the judge's words, and not give or repeat the claims.
Magistrates should also make clear that they reject such assertions.