All macros return strings. You can alter your macro to return a json formatted string using to_json, then use the from_json filter on your function call:
{%- macro list_entities_on(type, device_class='', state='on', select='', reject='', area='', exclude_area='') %}
{%- set ns = namespace(sensors=[]) %}
{%- if device_class and area %}
{%- for entity in type
| selectattr('attributes.device_class', 'eq', device_class)
| selectattr('entity_id', 'in', area_entities(area)) |
selectattr('state','eq',state) %}
{%- set ns.sensors = ns.sensors + [dict(entity_id = entity.entity_id, name = entity.name, state = entity.state)] %}
{%- endfor %}
{%- elif device_class %}
{%- for entity in type
| selectattr('attributes.device_class', 'eq', device_class)
| selectattr('state','eq',state) %}
{%- set ns.sensors = ns.sensors + [dict(entity_id = entity.entity_id, name = entity.name, state = entity.state)] %}
{%- endfor %}
{%- endif %}
{{- ns.sensors|to_json }}
{%- endmacro %}
{{(list_entities_on(states.binary_sensor, device_class='connectivity')|from_json) }}