With beet list ^media:cd I get the list of all non-CD tracks. But this doesn’t work with option -a, so beet list -a ^media:cd gives me all the albums in my library (as I understand, media is not an album field?).
Indeed, media is a track-level field because it’s possible for albums to consist of multiple media (e.g., a CD and a DVD). You could consider defining an album-level equivalent using the inline plugin, like this album-level equivalent of bitrate: https://beets.readthedocs.io/en/stable/plugins/inline.html#album-fields
…but you’d need to come up with a policy for how to do the mapping (e.g., using the first track or the majority).
This outputs, for each track matching the query, the name of its album, then sorts them, removing duplicates.
If you have multiple albums with the same title, you could also differentiate based on mb_albumid assuming your stuff is tagged from MusicBrainz—but that would be more complicated.