Done this a couple times, but really got the caching better last time so that it works perfectly... I've put in some fairly verbose comments, but if anything is unclear just shout.
/**
* Implements HOOK_preprocess_paragraph().
*/
function HOOK_preprocess_paragraph(array &$vars) {
/** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
$paragraph = $vars['paragraph'];
// Change 'content_reference' to be your paragraph bundle's machine name.
if ($paragraph->bundle() === 'content_reference') {
// Instead of 10 set that to be the max number of references in the field.
foreach (range(0, 10) as $i) {
// Change all references to 'field_content_reference' to use your field's
// machine name.
if (!isset($vars["content"]["field_content_reference"][$i])) {
break;
}
/** @var \Drupal\node\Entity\Node $node */
$node = $vars["content"]["field_content_reference"][$i]["#node"];
// Example change to the Node.
$node->field_parent_paragraph = $paragraph;
$changed = TRUE;
if (isset($changed)) {
// If we've changed the node, give a new cache id.
// THIS IS IMPORTANT!
$vars["content"]["field_content_reference"][$i]['#cache']['tags'][] = "paragraph:{$paragraph->id()}";
$vars["content"]["field_content_reference"][$i]['#cache']['keys'][] = "paragraph";
$vars["content"]["field_content_reference"][$i]['#cache']['keys'][] = $paragraph->id();
}
}
}
}
Follow that up with something like:
/**
* Implements HOOK_preprocess_node().
*/
function HOOK_preprocess_node(array &$vars) {
/** @var \Drupal\node\Entity\Node $node */
$node = $vars['node'];
if (isset($node->field_parent_paragraph)) {
$paragraph = $node->field_parent_paragraph;
$vars['content']['#attributes']['class'][] = $paragraph->field_settings_1->value;
}
}