The way I do it is using an external program, but it works super well, and doesn't get over written on updates: keyd. The advantage of using this program is that my custom layout works even in the tty.
KDE
KDE is an international technology team creating user-friendly free and open source software for desktop and portable computing. KDE’s software runs on GNU/Linux, BSD and other operating systems, including Windows.
Plasma 6 Bugs
If you encounter a bug, proceed to https://bugs.kde.org/, check whether it has been reported.
If it hasn't, report it yourself.
PLEASE THINK CAREFULLY BEFORE POSTING HERE.
Developers do not look for reports on social media, so they will not see it and all it does is clutter up the feed.
This looks very promising, thank you very much! I'll try it as soon as I can
I know this doesn't answer your question but have you tried the EurKey layout?
I did look it up, it's great and faster than my layout for the big languages – German, French, Spanish and Italian – because the accented letters are on the third and fourth levels directly and not written via dead keys, but it's harder to write most of the others like the Slavic languages (š, ů, ď, ł, ć, ̦ż, ą), Romanian (ș, ṭ, ă), Hungarian (ő, ű), Catalan ( · ), Azeri (Ə), Portuguese (ã), Turkish (ş, ţ, ğ, ı. İ) and Maltese (Ħ, Ġ). In EurKey each one requires Shift+AltGr+DeadKey+letter and a few are missing, while in my layout most of these require one less key. Of course this is not useful to most people, but I'm happy with it.
If you don't find software that works well, you might consider a keyboard with QMK or TMK firmware, or an older AT or PS/2 keyboard with a Soarer's converter. (I think I've even seen some hobbyist Soarer's converter variants that handle USB keyboards.)
One advantage of these is that, since they operate at the hardware level, they work in all OS and application environments.