There's multiple kinds of "locking" on devices. Click on the links below to find instructions on how to deal with your specific situation:
1) iCloud: Activation Lock - Activation Lock for iPhone, iPad, and iPod touch - Apple Support - This is a security feature so only legitimate (e.g., not stolen) use of devices is possible. Read this support article about how to remove Activation Lock --> How to remove Activation Lock - Apple Support - If an activation lock was put on a device, only the owner of the account that applied the lock can remove it. Get them to remove it or return the item for a refund. If you are the owner, see the part at the end about asking Apple to reset the device.
2) Device lock: If you forgot the passcode for your iPhone, iPad, or iPod touch, or your device is disabled, read this support article if you are using iOS or iPadOS 15.2 or higher --> If you see an iPhone or iPad unavailable message or Security Lockout screen - Apple Support or here if you do not meet the criteria for the previous method--> If you forgot your iPhone passcode - Apple Support
I am not sure what kind of locking you have on the device but whatever kind will likely require the log-in information for the account.
This article tells you the various ways you can try to discover your forgotten Apple ID --> If you forgot your Apple ID - Apple Support Typically an Apple ID is an email address you have used. If you are currently using a mobile device that is logged into your account, go to Settings and tap your name at the top. Look in Keychain, and in a browser's security settings if you use it to automatically sign into Apple when using a browser.
This article outlines what to do If you forgot your Apple ID password --> If you forgot your Apple ID password - Apple Support
or go directly to this link --> http://iforgot.apple.com/
If you find you can’t sign in, reset your password, or receive verification codes, you can request account recovery (read this support article: How to use account recovery when you can’t reset your Apple ID password - Apple Support ) to regain access to your account. Account recovery might take a few days or longer, depending on the specific account information you can provide to verify your identity.
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." Click here --> Contact Apple for support and service - Apple Support