Hello,
Windows Defender is malware protection that helps identify and remove viruses, spyware, and other malicious software. Windows Defender runs in the background and notifies you when you need to take specific action. However, you can use it anytime to scan for malware if your computer isn’t working properly or if you clicked a suspicious link online or in an email message.
Since Ransomware is a type of malware, Windows Defender should be able to protect your device from it. Take note though, that there is no such thing as a security software that can protect you from everything out there so caution is still advised.
You may also visit this link to know how to prevent and remove viruses and other malware for future reference.
Regards.