How do I alter webform values before submission?
The answer linked is mostly right, just a couple of updates to get it working. In a custom .module add:

use Drupal\Core\Form\FormStateInterface;

function MODULENAME_form_alter(&amp;$form,$form_state, $form_id) {
  if ($form_id == 'FORMID') {
    $form['actions']['submit']['#validate'][] = 'MODULENAME_form_validate';
  }
}

function MODULENAME_form_validate($form, FormStateInterface $form_state) {
  $form_state-&gt;setValue('hidden_id', 'Value for Hidden field');
}