How to return HTTP 404 when no search results found?

It’s bad practice to do so purely because the Search Results page was found it just returned no results.

A 404 would be used if the search page didn’t exist.