If your iPhone is passcode locked, see the following:
If you forgot a passcode that you changed within the last 72 hours, see the "If you recently changed passcodes, use your old passcode to temporarily sign in" section of: If you see a iPhone, iPad, or Apple Vision Pro unavailable message or Security Lockout screen - Apple Support
Otherwise, see the other sections of that article
If neither of the above is an option, you will need to use a computer. See: If you forgot your iPhone passcode, use your Mac or PC to reset it - Apple Support
or if it is your Apple ID account that is locked,
Apple has a support article that explains what to do when an Apple ID is locked or disabled. Click on the following link: If your Apple ID is locked, not active, or disabled - Apple Support