Warning
This will probably break many of adb functions such as "adb install", "adb shell pm", "adb shell appops", etc. if you are using non-system (non-platform) signing key.
You will need rooted device, adb, apktool (2.11.1 was used, on 2.8.1 i had compilation errors, other versions were not tested), android build-tools (keytool, zipalign and apksigner need to be in $PATH), and (optionally) custom recovery such as TWRP. Also you will need all tools that are needed to build scrcpy: https://github.com/Genymobile/scrcpy/blob/master/doc/build.md.
If you are doing everything while device is booted into system,
you need to execute adb root or add su -c to every adb shell command after shell, e.g.