If you run your own DNS resolver you can use the wildcard trick.
Something like this in an RPZ zone should do it:
facebook.com IN CNAME .
*.facebook.com IN CNAME .
facebook.net IN CNAME .
*.facebook.net IN CNAME .
fbcdn.com IN CNAME .
*.fbcdn.com IN CNAME .
fbcdn.net IN CNAME .
*.fbcdn.net IN CNAME .
fb.com IN CNAME .
*.fb.com IN CNAME .
fb.me IN CNAME .
*.fb.me IN CNAME .
tfbnw.com IN CNAME .
*.tfbnw.com IN CNAME .
should be unnecessary since the DNS zone above it, facebook.com is already CNAME'd. Most resolvers will take a CNAME as "any further requests go to here", which to my experience usually includes NS servers.
(This is also why you don't CNAME your root domain, CNAME conflicts with any other record type)
> What software actually parses /etc/hosts, at least on Linux?
glibc resolver
A good entry point for reading more about it:
$ man nsswitch.conf
If your /etc/nsswitch.conf file's "hosts" line contains the keyword "files", then it potentially uses /etc/hosts. If "files" is first (typical default config), it looks there first, before the other places listed.
This is done under the hood when programs use resolver functions like gethostbyname or getaddrinfo.
I don't use that list, I use Steven Black's [1] list has 1004 entries which is more complete than this list. It would be less, but more than 16. Even at that, you're right it would definitely reduce the size.
0.0.0.0 *.facebook.com