Set a Document File in a webform submission programmatically
To attach the file to a webform submission, you should get the file id first, and then set the file_attachment to file id.
Try this out.

  $webform_submission = \Drupal\webform\Entity\WebformSubmission::load(1);
  $data = $webform_submission-&gt;getData();
  // Get the document file object from uri.
  $document = \Drupal::entityTypeManager()
    -&gt;getStorage('file')
    -&gt;loadByProperties(['uri' =&gt; 'private://documentA.pdf']);
  // Get the file Id.
  $doc_id = reset($document)-&gt;id();
  // Set the file_attachment to fid. 
  $data['file_attachment'] = $doc_id;
  $webform_submission-&gt;setData($data);
  $webform_submission-&gt;save();