If you happen to have the original receipt, Apple can completely reset a device if a person can provide sufficient evidence of valid ownership. This is done online* at: Activation Lock support request - https://al-support.apple.com/#/additional-support Apple says, "Proof of ownership documentation is required," but does not provide many details in the article as to what is acceptable proof. Prior to this official service Apple typically required the original receipt** issued by Apple or an Apple Authorized Reseller. Note that while this will let you get use of the device again, it will not help you with lost access to an account.
* There is a special link for this service. To save time you should use it instead of https://getsupport.apple.com/
**Apple recommends you keep your receipt after you buy an Apple device. --> Keep your receipt after you buy an Apple device - Apple Support
If you do not have the receipt, read how to request access to a deceased family member's Apple account data, and possibly their equipment, read this support article --> How to request access to a deceased family member’s Apple Account - Apple Support
Apple says:
"While we may also be able to help remove Activation Lock from devices that use your loved one’s original Apple ID, their iPhone, iPod, and iPad will need to be restored to factory settings before they can be used with another Apple ID. Please note that devices locked with a passcode are protected by passcode encryption, and Apple can't help remove the passcode lock without erasing the device."
"For security, Apple requires and verifies legal documentation before we can assist with a deceased person’s account. This generally includes a death certificate, and may also require a court order or other documentation. The requirements vary by country and region. We have great sympathy for surviving family members and try to help with requests as much and as quickly as possible."