It depends upon the age of the computer and if it is a newer one with activation Lock capability.
If it is an older one, you can erase the drive and start fresh, or you can try to recover the Apple ID information:
About macOS Recovery - Apple Support - https://support.apple.com/HT201314 and related: Disk Utility for Mac: Repair a disk using Disk Utility https://support.apple.com/kb/PH22243
How to reinstall macOS - https://support.apple.com/HT204904 - including different recovery keyboard options.
To recover information:
Click on this link to read what to do "If you forgot your Apple ID" --> https://support.apple.com/HT201354 Note that typically this is an email address you use.
Click on this link to read what to do "If you forgot your Apple ID password" --> https://support.apple.com/HT201487
or go directly to this link --> http://iforgot.apple.com/
Also read about "What to do after [or before] you change your Apple ID email address or password" - https://support.apple.com/HT204071
If you still need help:
Contact Apple for help with Apple ID account security "This article provides country-specific Apple Support contact information for customers seeking help with their Apple ID password or other security-related issues."
https://support.apple.com/HT204169
For a newer Mac:
Click on this link to read about 'Activation Lock for Mac' --> https://support.apple.com/HT208987
In the case of Activation Lock you will need to either recovery the information or apply to Apple's Activation Lock removal service. Apple can completely reset a device if a person can provide sufficient evidence of valid ownership. Do this online at: Activation Lock support request - https://al-support.apple.com/#/additional-support Apple says, "Proof of ownership documentation is required," but does not state what currently constitutes proof. Prior to this new online service Apple typically required the original receipt issued by Apple or an Apple Authorized Reseller and documented provenance (so typically it would be the original owner who does this, or a descendant with legal proof of ownership).