Is it possible to alter html_head using hook_page_attachments_alter() per node?
Yes, when you get the current node.
/**
 * Implements hook_page_attachments_alter().
 */
function MYMODULE_page_attachments_alter(array &amp;$attachments) {

  $node = \Drupal::routeMatch()-&gt;getParameter('node');

  if ($node instanceof \Drupal\node\NodeInterface) {

    $attachments['#attached']['html_head'][] = [
      [
        '#tag' =&gt; 'script',
        '#value' =&gt; 'alert(&quot;' . $node-&gt;getTitle() . '&quot;)',
      ],
      'MYMODULE_foobar',
    ];
  }
}


If this really should be in a foreach, you need to ensure to give each tag an unique key.
foreach ($nodes as $node) {
  $description = [
    [
      '#tag' =&gt; 'script',
    ],
    ...
  ];
  $page['#attached']['html_head'][] = [$description, 'description_' . $node-&gt;id()];
}