You can hard reset your Sony Xperia Z5 by one of the following methods. You can also reset the mobile phone by way of the software called Xperia Companion which you can also find on this website. Note however that you will need to ensure that you have made a backup of your settings such as internet settings and your data if you wish to use it again after the factory reset.
Below you will find that there are a number of ways to reset your phone. The first is by menu which is done on your phone. The second is to reset the phone by way of the software on your computer such as the PC or Xperia Companion. The final solution is to reset the mobile phone by code which is also used by other Xperia mobile phones.
Hard Reset will erase all of your data
All described operations you are doing at your own risk.
Hard Reset Sony Xperia Z5 with Menu
Hard Reset Sony Xperia Z5 by Code