Communities like XDA Developers host unofficial builds of newer Android versions for legacy Sony devices.

Unofficial builds for Sony Xperia devices - Page 4 - iodé community

* Boot to recovery: with device powered off and the cable disconnected, hold Volume down & Power keys until the device vibrates. *

Updating these older devices is often restricted because official support ended years ago. However, you can still perform a factory reset or attempt to install custom software. Restoring or Resetting Your Device