Remapping of keys in Mac OS X

Try KeyRemap4MacBook. It seems to offer a lot of options. Maybe it will fix your problem as well. Here's what it says about it:

This is a very powerful keyboard remapper for Mac OS X. In addition to simple key remapping, it has special remapping modes like Emacs-mode, SandS-mode (Space and Shift).


You can use the hidutil command-line tool, which comes with macOS since Sierra 10.12:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'

The keys are referenced by Usage ID from the USB HID Usage Tables Specification. The section key § is listed as "Keyboard Non-US \ and |" (0x64, see https://discussions.apple.com/thread/8133633) and backtick ` is "Keyboard Grave Accent and Tilde" (0x35).