If you are still in your repayment plan, your bankruptcy attorney must file a motion for permission to incur new debt. The court must agree that you can afford the mortgage alongside your plan payments.
While the law and loan guidelines allow it, individual lenders (banks) can have stricter "overlays".
Lenders typically require at least 12 consecutive months of on-time payments to the bankruptcy trustee.