After a bit of playing around, it seemed messy to make it into a join, but we could replace the two array_agg sub-selects with a single one:
(SELECT pg_catalog.array_agg(ROW(attname, attstattarget) ORDER BY attnum) FROM pg_catalog.pg_attribute WHERE attrelid = i.indexrelid)
and then what we need could be pulled out of that, although I'm not sure if pg_dump has logic at hand for deconstructing an array of composite.
Digging some more on this, I see that we populate indxinfo[j].indkey as if it's an array of Oids, but it's an array of AttrNumber/int2. Shouldn't have caused any problems given that we're dealing with small integers, but it didn't help discoverability just now. Is there some history there that I'm not aware of?