In MAME, map them globally like so:
1237
4568
By default MAME assumes you have a 6 button layout like this:
123
456
so if you keep those core 6 like that, the majority of games will already be mapped correctly.
Here are the default MAME keyboard keys if that's what you're after:

If possible with your encoder, I recommend changing the first four to standard letter keys.
It will save you trouble down the road when you add other emulators that can't use those keys.
(I haven't run into any issues with the bracket keys on P2)
Also prevents windows hotkey combos from accidentally being triggered.