How to add JS to the search form?
In Drupal 8, you first need to define assets in a library in your theme or module: https://www.drupal.org/developing/api/8/assets

and then you can attach that library to your form like this:

$form['#attached']['library'][] = 'mymodule/mylibrary';