Create a draggable table and save weights
With the help from @Leigh I found the problem. I was setting some keys on $form['table'][$node-&gt;id()] and then overriding $form['table'][$node-&gt;id()] at the bottom.

I have moved a bit around in the code and now it works perfectly.

$form['table'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; [
    '',
    $this-&gt;t('Weight'),
    $this-&gt;t('Title'),
  ],
  '#attributes' =&gt; [
    'id' =&gt; 'my-module-table'
  ],
  '#tabledrag' =&gt; [[
    'action' =&gt; 'order',
    'relationship' =&gt; 'sibling',
    'group' =&gt; 'draggable-weight',
  ]],
];

foreach ($nodes as $node) {
  $weight = $node-&gt;weight;

  $form['table'][$node-&gt;id()] = [
    'data' =&gt; [],
  ];
  $form['table'][$node-&gt;id()]['#attributes']['class'] = ['draggable'];
  $form['table'][$node-&gt;id()]['weight'] = [
    '#type' =&gt; 'weight',
    '#title' =&gt; t('Weight'),
    '#title_display' =&gt; 'invisible',
    '#default_value' =&gt; $weight,
    '#attributes' =&gt; [
      'class' =&gt; [
        'draggable-weight'
      ]
    ],
  ];
  $form['table'][$node-&gt;id()]['label'] = [
    '#markup' =&gt; $node-&gt;label(),
  ];
}