This would have to be raised as an insanity defense. High bar to hurdle.
Depends on the state. There is also a “guilty with mitigating circumstances” plea in some places, which is what this sounds like.