There’s an option now to configure balance sheet nominal codes so you can use them on sales invoices. I’d create a new nominal for this in the “assets & liabilities” range and mark it as available for invoices, then when you assign lines to this code on your invoices they’ll show up as liabilities on your balance sheet rather than income on your P&L. The liability will disappear when you credit note the original invoice to return the deposit.
In cases where you do need to keep some of the deposit you’d have to journal the appropriate amount across to an income code once you’ve (part) refunded the rest.
P.S. I’m not an accountant, you may want a second opinion particularly if you’re vat registered.
Edit: This post explains it with screenshots.