Terminal.app has a setting "Use Option as Meta Key" that needs to be enabled. It's under the Edit menu as well as in Settings > Profiles > Keyboard (if you want, you can click use Command-A to select all the profiles to apply the change to all of them at once). Ghostty will have a similar option.
Also surprised you haven't encountered this earlier, given it affects all usage of Alt in the terminal.
Never had a reason to use alt or F-keys; I deliberately avoid them because they're not easily accessible by all terminals. Only programs I've seen these days use it are emacs and this edit program.
Also surprised you haven't encountered this earlier, given it affects all usage of Alt in the terminal.