Just have them weigh-in octagon side, minutes before they start to fight.
The problem is there is also the business aspect -- it would be weird to have fights canceled at the moment the guy is about to enter the octagon. There would also be weird scenes like someone being a bit over and the other guy refusing to fight and them arguing in the moment and hanging up the whole event.
However if they did what you said, I guess the UFC could protect their business interests by also doing their own monitoring of the training weight to ensure it was likely they would hit weight. So it could work.
Still would be better to figure out way where fighters fight at their natural weight. The current system is so artificial while adding a real element of danger.
Regarding the fighters looking after their own health risk that doesn't work because there is a conflict of interest. The trainers, promoters, and athletes themselves are biased to push the limit. Sure a doctor should be trustworthy, but they would literally need a doctor monitoring everything round the clock for the 48 hours leading up to the fight.