I'm not comfortable with these folks being in prison before they've had proper mental health care, honestly. Most folks with mental disorders are OK once they are stable with medication and sometimes need support to make sure they take such medication. We should more likely require by court order they stay their course and continue to receive proper help than try solitary first. This is how you treat the same folks as neighbors.
If this fails, prison is still not the proper environment - a live-in mental health hospital is much more appropriate.