There is a way! I wrote this tool exactly for this purpose, and works on both x11/wayland: https://codeberg.org/tubbadu/ktoggle
it writes a kwin script on a temporary file, installs it, runs it and uninstalls it. All using DBUS communication.
it works quite well (there is just rarely an unexpected behavior I didn't find the time to fix yet), I use it daily for lots of apps like telegram, whatsapp, qalculate and a note taking app
once compiled and installed you can just assign to a hotkey the command
ktoggle --class org.telegram.desktop --name telegram-desktop --program telegram-desktop
and you're done! read the readme to see an explanation of all available flags
(note: this is a work in progress, I have little time to maintain it, so don't expect it to be perfect!)
hope this helps!