This is a bit of a complicated question. Legally, whoever is named on the mortgage is responsible for it. This means that the bank or other mortgage holder can sue you for it.
In the context of a New York divorce proceeding, the judge can order that one party pay the mortgage, or can divide the mortgage payments between the parties. This is usually based on income. The judge can also make orders regarding child support, spousal support, sole occupancy of the house, and can order one spouse to pay all or a portion of the other spouse’s legal fees.
When the divorce becomes final, the judgment may continue to order one spouse to pay all or most of the mortgage. It may also order that the house be sold, and the proceeds be divided between the parties.