This is called a sitelinks search box and you'll see them pop up for huge sites. You simply need to have a search engine running on your site and add valid WebSite structured data. The code to get these is already found in Yoast SEO, but your site must be very authoritative will these appear in Google.