aggregating json fields
The error message is telling you that you can't use a set returning in the SELECT list. You need to put it into the FROM clause:

SELECT array_agg(t.k) 
FROM table tbl, jsonb_object_keys(tbl.data) as t(k) 
WHERE tbl.some_id = 3
GROUP BY tbl.some_id;