About 20 years ago while sitting in Annual Refresher Training a lawyer who was also the Associate Warden made this statement - Nothing is illegal in the line of duty until a Judge tells you it is illegal. Then you still have appeal rights clear up to the USSC.
That shock me to where I still recall that statement all these years later.
This video seem to confirm what I was told/ being instructed a few decades ago.
Another point at the end of the video.
In the Federal System Judges do not decide which prison a convicted person goes to. And seldom do they make recommendation. That determination is made after a verdict of guilty is made. Location of where the inmate is to be incarcerated is made at the Central Office level in Washington, DC.
I have no information about how the state courts parse out the convicted for incarceration.