How can I "form alter" fields in a nested Paragraph, depending on where the field is used
In this scenario, we have field_caption being used in various places inside a cta paragraph. The business has asked to limit field_caption to 25 charaters, but only when it is being used in a node on an entity reference field called field_foo_cta.

First we add a #process callback to the widget based on whatever rule, by implementing hook_field_widget_form_alter:

function mymodule_field_widget_form_alter(&amp;$element, FormStateInterface $form_state, &amp;$context) {
  $field_definition = $context['items']-&gt;getFieldDefinition();

  if ($field_definition instanceof FieldConfig) {
    $config = $field_definition-&gt;id();
    list ($entity_type, $bundle, $field_name) = explode('.', $config);

    if ($entity_type == 'paragraph' &amp;&amp; $field_name == 'field_caption') {
      $element['#process'][] = ['\Drupal\mymodule\BusinessRules', 'alterFieldCaption'];
    }

  }
}


Then we create a new class in src directory of the module.

namespace Drupal\mymodule;

class BusinessRules {

  public static function alterFieldCaption(array &amp;$element, FormStateInterface &amp;$form_state, array &amp;$complete_form) {

    // Use whatever logic to target instances of `field_caption`.
    if (reset($element['#parents']) == 'field_foo_cta') {
      $element['value']['#maxlength'] = 25;
    }
    return $element;

  }

}


Thanks @larowlan for help on this.