Now connect your iPhone via lightning cable and click on the “unlock lock screen” option.

As you can easily see, this method will be helpful if you forget your passcode or your lock screen is locked due to multiple incorrect attempts.

Connect your iPhone via lightning cable and click on the Next button.
It will ask you to download the latest firmware. Click on download and wait for the download to finish.

In case you already have a firmware file ready, you can use it instead by clicking on the select button.
Once the file is downloaded successfully, click on the unlock button.

Wait for a while, and it will remove the lock screen password and do a factory reset. Please note that your personal data will not be wiped out after removing the lock screen passcode.
In case you also wish to unlock the screentime passcode, then you may follow this guide to remove Screentime Passcode without Apple ID.
Factory Reset Your iPhone when Locked without Passcode using iCloud
If you have access to your iCloud account, then you can remotely erase and unlock your iPhone using iCloud. You can use this option if you have lost your iPhone somehow and dont have access to it.
Visit iCloud.com and log in with your Apple ID. Make sure to log in with the same account that runs on your iPhone.

Click on the Find my iPhone option here.

Locate your iPhone from the list of active devices.

Once you locate your iPhone here on the map, you can click on erase iPhone button.
Please note that it will erase all the data from your iPhone and will reset it to factory settings.
Factory Reset Your iPhone when Locked without Passcode via iTunes
If you have previously taken a backup of your iPhone, then you can restore it to that point, and your passcode will be removed. This can be a good option in case you regularly backup your iPhone. However, if not, then this method won’t help you much.
Download iTunes for your Desktop from here and install it.
Connect your iPhone to your PC via lightning cable.

Click on the Restore iPhone button.
Locate your backup file, and follow the onscreen instructions to flash it.
Note: If you have enabled Find my iPhone feature, then it will ask you to disable that feature.
If you dont remember your passcode, you will not be able to change the find my iPhone feature settings. This can be a bummer, but for many people, this feature is turned off, and hence they can restore their iPhone easily via iTunes.
Erase iPhone when Locked without Password by Erase iPhone on Lock Screen
If none of the above methods work for you, then you can also try disabling the screen lock to remove the passcode and erase your iPhone.
First, enter any wrong passcode multiple times, and it will lead to iPhone not available screen.
Your iPhone will be locked for 1 minute, and you have to wait for the time to enter the passcode again.

Once the timer is off, enter the wrong passcode again, and it will show you the option to erase iPhone.

Click on erase iPhone option and give relevant details. In some cases, it will ask you for your iCloud password or old lock screen passcode.
Once the process finishes, your iPhone will be erased, and you can set it up as a new device.
Note: This method only works on a limited number of devices only. Sometimes the option to erase iPhone comes when the iPhone screen is locked for 5 minutes or 15 minutes.
Conclusion
This is how you can easily fix the problem of Factory Reset/Erase iPhone when Locked without a Passcode. When we talk about iTunes and iCloud methods, they have their own restrictions as you ultimately have to log in to your iCloud account with multifactor authentication. But with PasscodeGo, you can solve all of these problems in one click, easy way.