How much does it cost to come out of a legally binding joint mortgage if an ex is buying you out?

You cannot "get out of" a mortgage. The mortgage must be paid off and refinanced in the name of the new single owner. That issue should be addressed in every divorce agreement.