How to add a colspan in a table header?
I just found the solution looking a bit in the Multi level (multirow) header for table FAPI element and doing some test.

This is the way that I found:

// The table header.
$header = [
  $this-&gt;t('Name'),
  $this-&gt;t('Description'),
  [
    'data' =&gt; $this-&gt;t('Weight'),
    'colspan' =&gt; 2,
  ],
  $this-&gt;t('Package'),
];

// The table.
$form['modules'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; [[1, 2, 3, 4, 5]],
  '#sticky' =&gt; TRUE,
];