Icon based on secondary attribute

I am using the 17track integration and a lovelace card with auto entities
i have managed different icons for different states
when the state is in transit they all show the same i would like to show a country flag based on the country in the secondary info

type: custom:auto-entities
card:
  title: Parcels secondary info test
  type: entities
  state_color: true
filter:
  include:
    - entity_id: sensor.*track_package_*
      options:
#        icon: mdi:truck
        type: custom:template-entity-row
        name: >-
          {{ state_attr('this.entity_id','friendly_name') |
          regex_replace(find="Seventeentrack Package: ", replace="",
          ignorecase=True)}}
        secondary: |-
          {% if state_attr(config.entity, 'location') %}
            {% if state_attr(config.entity, 'location') == "CN" %}
              China:
            {% else %}
               {{state_attr(config.entity, 'location')}}:
            {% endif %}
          {% endif %} {% if state_attr(config.entity, 'origin_country') %}
            {{state_attr(config.entity, 'origin_country')}}
          {% endif %}
sort:
  method: state

Thanks in advance