You can use a keyboard macro tool, but since Gmail shortcuts don't involve modifier keys, the challenge is making the shortcuts context-sensitive, i.e. you don't want them active in any place where you might be typing text (like the search bar or compose window).
I use Better Touch Tool and create a conditional activation group for this, with the following conditions:
- App Name is "Mail"
- Window Name begins with "Inbox —" (so the shortcuts don't trigger in the compose window; you can change this to suit your needs, but I personally only need them in the inbox)
- Focused Element Role is not "AXTextField" (so the shortcuts don't trigger when typing in the search box)
Then, you can add your Gmail keyboard shortcut triggers and actions to that group.
Side note: Launcher apps like Spotlight and Alfred are by default not considered separate windows. So, the keyboard shortcuts will still be active in them if Mail is the front-most window (i.e. the "App Name is Mail" condition is still true). For Alfred, there's a setting specifically to address this issue. Set Alfred Settings > Appearance > Options > Focusing: Compatibility Mode.