First of all is not a bitcoin problem.
Second, if you really are worried about your bitcoins, I think anyone here living in developed western countries can afford to buy a ledger cheap hardware wallet, this way the Ransomware cannot do anything to you if you don't have other important data in your PC. Just make a format and start with all your bitcoins in place again thanks to the hardware wallet.
As others have already said. It is very much recommended to back up all your data, including bitcoin wallet.dat if you have any.
Also if you have electrum wallet and have safeguarded the seed in few other places rather than your PC you can restore from the seed after you reformat your HDD.
Still ransomware is a very nasty thing.
Exactly. Offline wallet = no possibility of ransomware.