Hi
You have to follow these general steps (google for details)
1 Unlock the bootloader (Sony provides this functionality, so it is easy to unlock it)
2 Download - (from Sony Open devices site) Kumano software binaries for android 11 (Latest)
- with Xperifirm Latest android 11 image
- Newflasher (to flash the downloaded firmware)
- Unsin (te extract the boot image from the downloaded firmware folder; it is the sin file containing boot flash all in its name and it has around 65mb)
- Platform tools (for the fastboot)
- Xperia 5 drivers (Also from Sony open devices website)
3 Place Kumano software binaries in platform tools folder
4 Connect phone in fastboot mode (Vol up while connecting usb cable)
5 Flash the software binaries to both OEM partitions (fastboot flash OEM_a "software binaries.img" then fastboot flash OEM_b "software binaries.img")
6 Put phone in flash mode (volume down while inserting USB cable and release after vibration feedback while green led is ON)
7 Use newflasher and flash all content downloaded from Xperifirm (put newflasher in the root of the folder and execute it)
8 Boot phone (Now you have bootloader unlocked xperia with android 11 and no root)
For getting root with Magisk
9 Unsin the Boot image (place by drag and drop the sin file over the Unsin executable) and then move the img to your phone storage
10 Download Magisk on your phone
11 In magisk select install and select patch file, browse to the copied .img and patch it
12 Copy the "patched" boot image to your PC and place it in platform tools folder
13 Connect phone in fasstboot
14 execute fastboot flash boot_a "patched boot.img"
execute fastboot flash boot_b "patched boot.img"
15 fastboot -w (Do this to clear the Userdata. If you skip this your phone might not boot)
Reboot. Now you have android 11 with Magisk
P.s. : The Sony drivers contains a .inf file. Youn install them directly by right clicking the .inf file and select "install" or after you have connected the phone (in fastboot / flash mode) go to device manager and update driver, select have disk and browse to the .inf file)
Also there are several tutorials here in Xperia 5 sub forum that are very detailed.
Sorry for any mistakes!