If there was a driver in a Lockyer-esque situation in F1, Gary Hartstein would simply say “you’re not driving”. Driving in contravention of such an order from him would be a breach of the driver’s Superlicence, so they wouldn’t be driving in F1 again whether they came to harm in the race or not. The teams know this and would prevent their driver from having the car in order to protect their ability to compete for them in the future.
There have been a few occasions where drivers have competed when they probably shouldn’t have done, by successfully hiding the true extent of their injuries from whichever doctor was on duty at the time. This does not mean, however, that they get to compete – Martin Brundle crashed in qualifying at Monaco in 1984 and tried to go back out on track despite concussion (Martin estimated later he was about 30% conscious at the time). When Ken Tyrrell heard him ask, “Which way do I turn at the end of the pit lane?”, he stopped the car and insisted Martin cease attempting to qualify.
The other one I remember well was when Giancarlo Fisichella fractured his knee in a testing accident close to the start of the season. Normally, this would be enough to be barred from competing for a while, but somehow the truth got hidden for several months, aided and abetted by the team. This in itself would count as pretty inadvisable, but crashing heavily in the second race of the season – when the knee was presumably still healing and caution would have been the order of the day – takes the matter into “idiocy” territory…