I would consult counsel first and I think it depends on what account you want to credit. If there is a residual loss balance and funds in escrow, you may be able to allocate the escrow to tax or insurance costs the escrows were for. To take specially designated funds and apply them against a loan balance is the bank acting in its own interest instead of using the funds for the T&I they were deposited for. That may not go over well. Counsel could determine better if there would be issues or another way to get the funds for the bank. If the debt is all but exhausted perhaps a judgment could secure the escrow funds for the bank.
If the debt is unrelated to the escrow it would be much more difficult (to impossible) to take those funds and leave T&I unpaid.
I've seen the question before, but only done minor research as I have never actually had this scenario myself.
My opinions are not necessarily my employers.
Rules and Regs minus Relationships equals Resentment and Rebellion. John Maxwell