- you cannot apply for a school place until you are resident here.
BUT
for grammar school, you need to take the 11+ at the beginning of year 6. At the time of taking the exam you do not have to be resident. But the timing is very tight, you have to fill in the application form by 31st October in year 6, with a uk address.
The rules vary from place to place. There are boroughs/LEAs that used to allow you to take the 11+ overseas at your nearest embassy. But I have a feeling that no-one does this any more.
Depending on the grammar school, where you live for your application may be irrelevant, as long as you pass. eg the school accepts applicants from the highest score down, regardless of where they live. (within UK) Added to that, although you apply in Oct, the address is confirmed in dec/jan, so technically you could take the exam, then move back to anywhere in UK and put in your application form, while you sorted out housing/gave tenants notice etc.
But, unfortunately, the only way to be sure is to return to UK before the test is taken in sept of year 6.
If you return later, you will be a late applicant, or an in-year applicant. At that point the places are already filled, but you can go on a waiting list and get in if someone doesn't take up a place, or leaves.
My brother and SIL were facing this, and ended up with one of them and their eldest daughter returning to UK in sept year 6 and renting a house, while the rest of the family finished up overseas and moved back during the year. It was not great to be honest.