To answer your question directly: yes, you can technically perform an in-place upgrade on a DC, but from my experience, I get very nervous about that path when we already know the OS is corrupted. It's like trying to fix a crack in a building's foundation by repainting the walls—it might work, but if it fails, the situation is often much worse.
The "gold standard" here, and what I'd recommend for maximum safety, is to build a new, clean server and promote it to a domain controller. This isolates the problem and gives you a known-good server to fall back on. Once the new DC is healthy and replicating, you can then safely decommission the corrupted one.
If you're absolutely forced down the in-place upgrade path due to time, your checklist is critical:
First and foremost, make sure you have at least one other fully healthy DC running elsewhere (and ideally, a solid system state backup of this one).
Move all the FSMO roles off this box and over to that healthy DC before you even think about starting the upgrade.
The "Keep Files" option is the one you'd want, but have a rollback plan ready.
It's a high-stress operation, so please proceed with an abundance of caution. Let me know if you need a second pair of eyes on your backup and role status before you pull the trigger.
If this helps clarify the path forward, would you mind hitting "Accept Answer"? 🙂 It lets others know what worked.
All the best.