The UK government has a very extensive web page explaining how to self-isolate when arriving in the UK from abroad. With some caveats, your plan is doable, but perhaps not recommendable.
First of all, you are allowed to self-isolate staying with friends or family and as you already pointed out, you are allowed to leave the isolation for the purpose of travelling out of the UK. You should however also consider the following:
Credit:stackoverflow.com‘
4 Mar, 2024
5 Mar, 2024
5 Mar, 2024
4 Mar, 2024
5 Mar, 2024