This a question to ask your lawyer.
Lets say there is no divorce and remarriage involved. Two people (A&B) are on a mortgage and the deed, and you want one persons (B) off the mortgage and deed and another person (C) added to the mortgage and deed.
The lender would have to approve the switch. They would need to know that either you (A) alone, or you and the new person (A&C) can afford the loan and that C's credit score isn't terrible. Since they have the lien they would have to approve the adding of C to the deed, because they may have a policy that the people on the mortgage must equal the people on the deed.
Of course B would also have to approve the change in deed because it would change the ownership structure. There will be paper work.
There will be costs for the credit check, and the paperwork that will have to be submitted to local government. The local laws will determine other costs. Some jurisdictions may consider this a sale that triggers a reappraisal of the property value. This can be a minor thing, but it might also be a big thing if the jurisdiction caps the property tax increase except on ownership changes. Catching up on 10 years of deferred increases could involve a significant change in property tax due next year.
It could also require a new title search and title insurance policy.
Now if this is part of a divorce settlement, then some of these things change. The switch is being ordered by a judge so the lender may be more forgiving regarding their reluctance to approve the changes, but if A alone or A&C can't afford the payments then they might not ever approve the switch.
Being part of a divorce settlement may also avoid the the local government from calling for a reappraisal.
The lawyer should have a advice regarding the local processes involved or have access to somebody who has that expertise.