It's not legal for a US state to declare bankruptcy. There are three relevant parts in the US Constitution that preclude this action. One says that US states are not allowed to abrogate their contractual obligations (pensions, debts, etc). Another says US states are sovereign in their own right. The Federal government cannot act on them directly. All bankruptcy procedures (personal, corporate, municipal) are dealt with at the federal level. Having a federal court process a state bankruptcy would violate state sovereignty, because the federal government would be acting on a state directly.
A law would have to be passed and there would probably be a challenge to it that would eventually go before the US Supreme Court.