There's some very conflicting dynamics with liability.
Malpractice is based on a geographic standard of care treatment. Things in the middle of a rural area are lower quality care vs in the middle of NYC. So the possibly literal million dollar question is does the jail have a differing standard of care? Is it's geographic standard like Vatican City where it is it's own thing? I've never seen anyone answer the question.
Then add to this treatment in a jail is often times poor despite the best efforts of the psychiatrist. Even if you try to do a good job, you might not be able to do so based on various constraints often times outside your power. E.g. the jail may have a limited formulary, what if the PCP in the jail is a piece of crap and you know that PCP isn't doing jack and you can see problems that other doc isn't treating, but it's outside your own speciality, often times complete lack of knowledge regarding the patient's prior history, and there's no easy access to the outside world, plus the social worker who could bridge that gap could suck eggs.
So who's liable? Usually the state covers you, but I've seen cases where the state government told the doc they're covered, but with the first lawsuit pretty much told the doctor they woudn't cover, "you're on your own," and when the doctor protested, the response was "so okay sue us, and you'll win in court 10 years later. We're the state so we can delay the lawsuit for your entire career. You'll end up doing what most do. You'll suck it up, pay for it yourself, and move on cause it'll be a second full-time job fighting us for 10 years."
Did the above really happen? Happened to a friend of mine. The people in the state then asked me to take over his job when he decided to leave that toxic job. I said no. I was already planning on leaving the place, but that event just reinforced this was the correct decision.
From my own experience most jail psychiatrists are horrendous. Of course there are exceptions. Some are forensic professors who've incorporated the jail into their department's program, but this is rare. Then there's these for-profit organizations where the top doctor puts naive doctors into the role of working in piece of crap facilities, where the facility is willing to pay $400,000+/year, but this scumbag (or genius depending on how you look at it) pays this naive doctor $200K/year and takes in the rest into his own pocket where he pretty much just puts in about 2-3 hours a week into that job, making the naive doctor do a lot of hard work. I can name you organizations that operate this, but not on the forum for obvious reasons. I know of an organization that has several doctors working in that organization, and the head doc takes in a very unfair fraction, while these docs have no idea that this guy is raking in millions while they work their tail off.