Apple has a process for this, but there are a few levels of process:
https://support.apple.com/en-us/HT208510
If you just want to delete the Apple ID (which would allow you to format the Mac and set it up as a new one without getting stuck on the activation lock), you can do that pretty easily with a copy of the death certificate.
If you want actual access to the Apple ID so that you can login as your cousin and access the data, you'll need a court order - which will be easy to get if you are the beneficiary of your cousin's estate (or the mac specifically). Apple are pretty tight on privacy, and you'll need to prove you have the right to access the deceased person's data - just being a relative isn't enough in Apple's view, you need to prove the deceased intended you to have access.
If your cousin added you to the AppleID as a legacy contact before they died, you can get access easily here (but I'm guessing not if you're asking this question):
https://digital-legacy.apple.com/
If you have access to your cousins e-mail account, then use the Forgot Password option at iCloud.com to get a reset link - that's the easiest way.