In this answer I am using the term "slavery" as it was understood in legal writing when the 13th amendment was passed. Other forms of forced labor or involuntary control would not have been covered by that term at that time, even though the term slavery may be applied to them in modern use.
At the time that the 13th amendment was passed, it was common to sentence criminals to "imprisonment with hard labor". This is now less common, prison jobs being regarded as something of a privilege, but that is a change of policy, not of law.
Forced prison labor is, arguably, a form of involuntary servitude, but not a form of slavery. For one thing, a slave (in US practice) could be freely sold. Prisoners may not be sold, although in the past their labor was often rented out by governments to private parties.
For a second thing, slavery was permanent, there was no such thing a slavery for a term of years or any limited period of time.
For a third thing slaves retained few if any rights, and had no way to present a legal appeal or to challenge their enslaved status; prisoners do.
For a fourth thing, the children of female slaves were also slaves, there is no such thing as hereditary criminality in the US.
For a fifth thing, any person could,own slaves, only the government (or those contracted to act for it) may hold convicts in prison.
Section 1 of the 13th amendment reads:
Neither slavery nor involuntary servitude, except as a punishment for crime whereof the party shall have been duly convicted, shall exist within the United States, or any place subject to their jurisdiction.
Whether the exception for "as a punishment for crime " applies to "slavery" as well as to "involuntary servitude", is to the best of my understanding, and unsettled question in US law. This is because no US State or Federal legislature has, since the 13th was ratified, passed a law imposing a sentence of slavery for any crime. Thus there has been no occasion for any US court to take up the question of whether such a sentence is constitutional under the 13th, or under the 8th's prohibition of "cruel and unusual punishment". I rather suspect that such a law would be struck down, but no one can be sure of that unless such a case is brought to court. I am confident thsat any law imposing hereditary slavery as a punishment for crime would fall afoul of the prohibition on "corruption of the blood" (hereditary forfeiture for treason or other serious crimes).
A US Judge, state or federal, may only sentence a criminal to a penalty authorized by law. There being no law providing for such a sentence, any such sentence would be blatantly unlawful, just as a death sentence for jaywalking would be. Any convict can appeal a sentence not authorized by law, and such an appeal would normally be granted if the judge had in fact gone beyond what the law permits in the way of a sentence. Even if such a sentenc is permitted unde the constitutioin, it is not permityed for a judge to impose it in teh absence of a specific law authorizing that sentence.
If any such law were ever passed, then and only then could a judge lawfully sentence someone to slavery, subject to a challenge to the law as being unconstitutional.