I got this warning on Debian Trixie with Gnome.
setxkbmap -option "caps:swapescape"
WARNING: Running setxkbmap against an Xwayland server
I was able to successfully remap caps to escape with:
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']"