Surprisingly, this is not something that comes up often. There are quite a few emulators that don't have native controller support and rely primarily on the keyboard. I don't run any of the MSX emulators on RetroPie, but I assume this is the problem. Even if RetroArch allowed core remapping for MSX, I doubt it would allow f-key mapping to controllers.
If you really want to achieve this, you'll need to familiarize yourself with a keymapping program. This technique is completely off the beaten path, but has been achieved in RetroPie by others. Below is the link to a guide that explains the process as it relates to KODI. You'll need to adapt that information to the keyboard controls you wish to map for MSX.
http://blog.petrockblock.com/forums/topic/mapping-a-game-controller-in-kodi/
I'm currently working in this direction with a few emulators in my own setup, so if you have any further questions, I may be able to help.