The downside is that you lose the ability to write those English letters. I managed to do it by holding down AltGr but that might be related to me also having the US International keyboard (don't ask, X is a mess).

You can add an Esperanto keyboard layout. That is done differently for different graphical environments, assuming a graphical environment. The effect is that you can now switch to the new layout and type in Esperanto. It is QWERTY but some of the English letters have been replaced with Esperanto ones. Specifically:

If you are using the US layout, you can change that to the US Internation with dead keys at AltGr. Then you can type the Esperanto characters like that:

This requires to execute a command, and assumes you are using the “X window manager” (you most likely are) with single layout. So, just execute:

setxkbmap -option esperanto:qwerty

This makes your normal US layout (International or not) work in a new way. Now when you hold AltGr and press a letter, you get the accented one. So AltGr+c → ĉ, AltGr+s → ŝ and so on, also AltGr+u → ŭ.

This works only for the current session and current layout, so you’ll have to do it at every computer start. However, that is easily fixed, just make that command execute at every login in the graphical shell (there are various methods, search the Internet). At least for me, however, this breaks the Alt+Shift toggling between keyboard layouts (I also have Bulgarian layout). So to fix that, I have to also execute (after that command):

setxkbmap -option grp:lalt_lshift_toggle

And that’s it. Just add (if you need to) that command to that start-up script after the first one.