If your device is locked, you can erase and unlock it remotely via Google's "Find My Device" or Apple's iCloud.
Android
- Go to google.com/android/find
- Sign in to your Google account if necessary.
- If you have multiple devices, select the correct device.
- Select "Erase device data" > "Erase all content on the device"
Apple
- Go to icloud.com/find
- Sign in with your Apple ID and password.
- Click "Find Devices/All Devices" at the top of the screen.
- Select "Erase [device]" and confirm with your Apple ID password.