Thanks for your question.
This is potentially possible.
You could do this by loan agreement for the shortfall, I.e that amount of the deposit. This could either be repaid monthly or lump sum on resale. To protect your position this arrangement should be in writing and registered as a legal charge (it will have to be a second charge and rank behind the mortgage) with a restriction put on the title, preventing a sale, lease, remortgage etc without your consent that the terms of the agreement have been complied with.
I hope this helps. Do let me know if you have any queries.
Please can I ask you to accept / positive rate my reply so that I receive credit for my time in responding to your query. Happy to keep assisting thereafter.