On different flavors of *nix you have "compose character" that helps you with that. In my sway config I have
xkb_options grp:win_space_toggle,compose:caps
and then I can do compose ss for ß or compose SS for ẞ.