We can easily hide the Search feature from users in Dynamics 365 Portals. There is no any role of developer to do this by writing any code. Here are the steps to do it.
Update a Site Setting record
In Dynamics 365, navigate to Site Settings and open the "Search/Enabled" record. Update the Value field from "true" to "false." Save and close the Site Setting.