/**
 * Implements hook_field_widget_settings_summary_alter().
 */
function {{ machine_name }}_field_widget_settings_summary_alter(array &$summary, array $context) {
  // Append a message to the summary when an instance of foo_widget has
  // my_setting set to TRUE for the current view mode.
  if ($context['widget']->getPluginId() == 'foo_widget') {
    if ($context['widget']->getThirdPartySetting('my_module', 'my_setting')) {
      $summary[] = t('My setting enabled.');
    }
  }
}
