I really think the information about the accused's or the offender's mental health can affect two elements of the judge's sentencing and lead to better sentencing—fairer, just, and more humane sentencing.
The first has to do with whether or not there is some limited moral blameworthiness because they didn't fairly understand the nature of their behaviour and the consequences of it. This goes to the quantum of the penalty: there has to be a direct link between the mental health issue at the time the offence was committed and the quantum of the penalty.
The second element is more general. If you're assessing what would be the best sentencing option, let's say that the person has a brain injury such that they can't process causality. The fact that they have hit someone may not be relevant to the offence, but it might be relevant to what kind of sentence the judge should be imposing, if you actually want the person to be able to comply with the sentence and fulfill its terms and conditions.
It's a bit subtle for me, in that you might want more information when you're looking at the range of sentencing options and saying that this person reacts very badly to confined spaces. Maybe that didn't have anything to do with the offence, but maybe they are going to act out or have real problems if you put them in administrative segregation or some other confined space. This could affect the sentencing judge's determination of what the appropriate sentence should be.