Yup You can! You just need to instal custom ROM like Lineage OS - you can now run Android 12 on Z5. Mine works like charm. Lineage 19.1 with Magisk and this old phone can do wonders 😄
Just google - zenfone 5z lineage os - you will find full instruction. You just open bootloader and via adb instal new ROM. Remember that clean Lineage os is without google services - you need to add it (there is annotation in instruction).