Use the OpenSearch specification [0]. Most search engines and even websites support it. It’s how, for example, you can search YouTube directly in the FF address bar.
Interestingly, Safari at least used to support the first - if you type something into the bar on a site which advertises opensearch, those results will be incorporated into the displayed list.
For the global behavior, the guidance seems to have shifted from opensearch plugins to web extensions. Safari does not seem to support any of the search engine metadata fields currently.