If you seek a heuristic way to prevent ransomware on Mac, RansomWhere[1] by Objective-See is awesome and free of charge. It constantly monitors the file system, and if it sees a sudden burst of encryption, will freeze the concerning process. Yes, you'll 'lose' at least a few files, but major loss is prevented. Obviously, you'll need to turn it temporarily off if you want to do any legit encryption.
[1] https://objective-see.com/products/ransomwhere.html