Recently I worked a lot with Drupal 8 Form API and as always you need to add some attributes to your form element to avoid doing everything in the template file (which is not recommended).
You won't find what is following easily within Drupal documentation.
This is a standard form element.
$form['element'] = [ '#type' => 'texfield' // or whatever expect DateTime. '#attributes' => [ 'class' => [ 'input_class' ], ], ];