The Eighth Amendment to the U.S. Constitution bans cruel and unusual punishment, which has been interpreted to bar a death sentence for one who suffers from mental illness to the degree that he or she does not understand the nature or consequences of the underlying crime leading to a death sentence. This is a rare situation, but the issue can arise and the following link summarizes one such case – https://www.greghillassociates.com/death-sentence-reversal-s-mental-illness.html