I used Karabiner-Elements to remap F4 to Alfred 5
You need to change karabiner.json, the file is located in the config folder of Karabiner Elements. I used Visual Studio Code but I think most Text editors will do.
Open karabiner.json
Search for "spotlight"
Replace "apple_vendor_keyboard_key_code": "spotlight" with "shell_command": "open -a 'Alfred 5.app'"
Depending on the number of keyboard-profiles you have in Karabiner Elements you need to do it for every keyboard-profile.
File, Save
Restart Karabiner
The mapping for F4 should look like this. Note that I changed F5 and F6 too but that's not relevant to this topic)