Here is my solution with a custom form theme. I copied the standard widget_attributes block and added the code between {# ADD ERROR START #} and {# ADD ERROR END #}. You just have to replace the value in {% set errorClass = 'error' %} with your error class.
This solution adds the specified error class to all widgets with errors.
{% block widget_attributes %}
{% spaceless %}
{# ADD ERROR START #}
{% if errors|length > 0 %}
{% set errorClass = 'error' %}
{% if attr.class is defined %}
{% set errorClass = errorClass ~ ' ' ~ attr.class %}
{% endif %}
{% set attr = attr|merge({'class': errorClass}) %}
{% endif %}
{# ADD ERROR END #}
id="{{ id }}" name="{{ full_name }}"
{%- if read_only %} readonly="readonly"{% endif -%}
{%- if disabled %} disabled="disabled"{% endif -%}
{%- if required %} required="required"{% endif -%}
{%- if max_length %} maxlength="{{ max_length }}"{% endif -%}
{%- if pattern %} pattern="{{ pattern }}"{% endif -%}
{%- for attrname, attrvalue in attr -%}
{{- " " -}}
{%- if attrname in ['placeholder', 'title'] -%}
{{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
{%- elseif attrvalue is sameas(true) -%}
{{- attrname }}="{{ attrname }}"
{%- elseif attrvalue is not sameas(false) -%}
{{- attrname }}="{{ attrvalue }}"
{%- endif -%}
{%- endfor -%}
{% endspaceless %}
{% endblock widget_attributes %}