I'm on Android Pie as well, and under the keyboard settings (Language and Input), there is a physical keyboard section which lists out the shortcuts available (example). If your keyboard doesn't come with a function key, you may need to find a mobile equivalent to AHK that can bind a certain key input or combination to invoke the meta key input. Also note you may be able to send a keyinput event through ADB or your device's local shell terminal, which then might be made more accessible through various automation methods, some of which may have device-dependent factors.
Note: though it doesn't seem to appear on the list, I distinctly recall Alt+F4 working with a keyboard? Will verify on current device when I get the chance.