Sobre la base de la solución de @Georges Martin, no usaría una unión lateral y una cláusula de agrupación, sino solo una subconsulta anidada:
SELECT XMLELEMENT(
NAME "Company",
XMLATTRIBUTES(id AS id, field1 AS field),
(SELECT XMLAGG(
XMLELEMENT(
NAME "companyTag",
XMLATTRIBUTES(
attr.key AS "tagName",
attr.value AS "tagValue"
)
)
) FROM JSONB_EACH_TEXT(attributes) AS attr)
) FROM comp_emp;