Add variables in custom input template
Declare a #theme starting with the base hook of the input element and a double underscore:

  $form['my_field'] = [
    '#type' =&gt; 'textfield',
    '#theme' =&gt; 'input__custom',
    '#icon' =&gt; 'my_icon',
    '#title' =&gt; $this-&gt;t('My title'),
  ];


Prepare additional variables in a preprocess hook:

function mytheme/mymodule_preprocess_input(&amp;$variables) {
  if ($variables['theme_hook_original'] == 'input__custom') {
    $variables['icon'] = $variables['element']['#icon'];
  }
}


Then you can use the added variables in the input template:

{{ icon }}