If you use Vi editing mode in the shell, then swapping two characters is easily done by just typing
xp in normal mode ("command mode", i.e. after pressing Esc). This literally means "erase the character under the cursor" followed by "paste the previously yanked text (the deleted character) after the cursor".
This will work in all
sh shells. Vi mode is descibed in the POSIX standard.
In Emacs editing mode, the same operation is often bound to Ctrl+T (
T for "transpose").
There is no completely shell agnostic way to do this. The above works in
zsh, but the Emacs command line editing mode is not standard (as in POSIX standard).
This is from the rationale section of the above linked page:
In early proposals, the KornShell-derived emacs mode of command line editing was included, even though the emacs editor itself was not. The community of emacs proponents was adamant that the full emacs editor not be standardized because they were concerned that an attempt to standardize this very powerful environment would encourage vendors to ship strictly conforming versions lacking the extensibility required by the community. The author of the original emacs program also expressed his desire to omit the program. Furthermore, there were a number of historical systems that did not include emacs, or included it without supporting it, but there were very few that did not include and support vi. The shell emacs command line editing mode was finally omitted because it became apparent that the KornShell version and the editor being distributed with the GNU system had diverged in some respects. The author of emacs requested that the POSIX emacs mode either be deleted or have a significant number of unspecified conditions. Although the KornShell author agreed to consider changes to bring the shell into alignment, the standard developers decided to defer specification at that time. At the time, it was assumed that convergence on an acceptable definition would occur for a subsequent draft, but that has not happened, and there appears to be no impetus to do so. In any case, implementations are free to offer additional command line editing modes based on the exact models of editors their users are most comfortable with.