Can a hospital legally deduct from your paycheck to cover an unpaid balance?

Yes

Let me explain:

It is legal for a hospital to deduct the amount of an unpaid medical bill from your paycheck if you have provided written consent for this deduction.

Medical Billing - Related Articles