This sounds terribly similar to an
XY problem (you ask about your attempt instead of asking about your real problem). Why do you even want to remove a driver for a device that you're still using? Or if you're no longer using it, why have the thing attached to your computer? It doesn't makes sense to me.
But there's still nothing preventing a ransomware from turning it back on and messing with it. It was better before when it couldn't even know the drive exists.
It seems like you want to uninstall the driver to "protect" the hard drive contents. This is a bad approach for a security problem.
The very first barrier a malware would be stopped is
permissions. Windows has a very strong security system in place, so use it. Deny your user access to critical files, and allow administrators-only access. Malware would need to achieve administrator privilege scalation to tamper with anything. Deny read access to admins and you're pretty much locked the files from anyone (this is the same trick the service user "trustedinstaller" does).
BTW, once the malware has achieved admin access, you've already lost. If you use a proper permissions system the malware can always give itself permissions, if it's intelligent enough. If you uninstall the drivers malware can always reinstall them.
But again, I ask, what's your
real problem here?