In theory it should work. Boot to twrp and execute the script. It rewrites the kernel-partition for magisk understandable format. You can flash magisk.zip now. After it finished, continue the script and it will rebuild the kernel with magisk updated ramdisk.cpio. Meaning you will get a boot.IMG (which is zImage directly) with magisk in it.
I didn't test it without sdcard. You can try. Keep ODIN ready if the kernel is messed up.
I did a test yesterday. Boot to twrp and execute the script from ubuntu bash (Windows subsystem for linux). But comands like cout and mkbootimg are unknown. I think i have to install some packages.