Short answer, company Y cannot reclaim the VAT unless i) company Y registers for VAT and ii) company Y "opts to tax" the property and iii) rents the property to company X at commercial/market value rents. Opting to tax is irrevocable for 20 years and will mean any future rents or sale will be subject to VAT. Opting to tax requires a specific formal process of notification to HMRC, which can be done at same time as when registering company Y for VAT. In addition, because company X and Y are connected persons (same ownership) and because the value of the purchase is over £250k, then there are anti-avoidance rules that apply where the tenant occupying the property is an exempt or partially exempt business. You don't state what company X does/sells but a business if company X is not registered for VAT but able to lend £500k to company Y, then it suggests company X is an exempt or partially exempt business (but there could be other reasons why company X is not registered for VAT).
Opting to tax land and buildings (VAT Notice 742A) explains the option to tax rules and section 13 deals with the anti-avoidance rules.
VATVAL07300 explains the rules where a VAT registered seller (company y) makes sales to a connected person (company x) who is not VAT registered and where market value rules apply.