That's what they do or used to I'm a retired psych nurse and worked with criminals and criminally insane adolescents. Murdering children and teens are a scary bunch. The bad thing is the State tries to show their system works and puts pressure on staff to get them out before they make it to age eighteen. Lot of problems in that last sentence. Creates conundrums and worse for those knowing patients and those in juvenile halls are not ready for the outside and yet it's usually a decision with Sacramento people and staff who work with them days and night are ignored for their graphs.
Judges listen to the psychiatrists and maybe, maybe call on staff but ultimately they read report summaries.I don't believe it's any better now. Ultimately it's the psychiatrist, the judge and the social worker(s). The initial court cases can take awhile and they decide whether they're tried as adults, go to Juvenile Hall or a state hospital etc. From there they get conservator-ships or have parents and advocates and up for review usually six months for minor and a year for the major crimes but they do try to push them to leave before their eighteenth birthday.
For the heinous crimes they go to prison but in state hospitals( think they're closed for under eighteen now) if they're still deemed dangerous they just got walked to adult units.
I worked for the CYA for 28 years. We went through cycles becoming more punishing (which was needed after decades of low sentencing). We can issue punishment which fits the crime and still treat them differently inside in terms of education etc.
Unrelated, the entire system now is loaded wth mental health cases. We have mental health cases on the street and 55% of inmates on, psychotropics. All to close the hospitals.
Best wishes.