Assuming it's a weekday there is an 0440 from York, arrive Kings Cross at 0700. Add an hour on the tube/Elizabeth Line/Heathrow Express to Heathrow, that is 8am, for an 11am flight. I would add on an hour for general bad luck. That is 12 noon, the earliest I would consider.
The next train is at 0555, arrive Kings Cross 0801, so that is a 1300 flight.
Then trains at least every 30 minutes from York.
Now the 0440 is an IC225- an older and way nicer train type than the usual Azumas, some compensation for being up so early.
I would be leery of doing that, because the unknown can happen. Only a few days ago one afternoon LNER had the twin disaster of a major power failure between York and Doncaster, and then a human tragedy as well when someone intentionally stepped in front of a train. The effect was delays of up to nearly 5 hours on trains which ran, with many cancellations. Due to trains and crews being out of place (and out of working hours) there were knock on effects well into the following morning- the 0440 was one of the trains cancelled, others ran with significant delays.
Such heavy delays and multiple simultaneous incidents are not at all normal, but incidents always happen when you least want them to. One time last year I was on the sleeper train from Cornwall, when we had such a personal tragedy in front of my train and we ran 3 hours late into Paddington. Anyone with a flight would have been in a pickle. To be honest I was also emotionally shot next morning. Luckily I was heading for Peterborough that morning, and knew exactly where to get a very good breakfast (Euston 1st class lounge) on the way, to look after myself.
So I would want to go down the previous evening- trains run half hourly all evening from York until 2130 (arrive KC 2320) and then 2259 arrive 0144. Then get a Premier Inn (other budget brands exist, as they say) at KC or continue through to Heathrow and a hotel there. Prices both at KC and the budget chains at LHR are normally very reasonable booked this far out.