You can buy the registration number in advance as it will be owned by you throughout, including whilst it’s on the Motability car. I can’t recall the exact terminology but you can also have an ‘assignee’ (from memory) which, in this case, will be Motability Operations as the registration number will be assigned to a car belonging to them. You can then put it on ‘retention’ towards the end of lease so that you retain the rights to the number.
Just a tip from experience, but I always allow a new car to be registered first with a ‘normal’ number. At a later date I then assign the personalised number. It’s quite cheap to have the plates made up and fitted at Halfords. I then keep the original plates so that when the car is due to go back it’s a 5 minute job to put the original plates back on (if a car has had a normal number from new it’s always allocated that same number back again when you remove a private plate).