What happens
- Your legendary survives any attack with 1 HP, thanks to its bond with you.
- The game prompts you to Terastallize and use Tera Blast.
So there is no need to worry about preparing or having to redo the battle. The fight is meant to be a story moment more than a challenge.