"extra_hosts" not working correctly

All extra_hosts does is add that line to the containers /etc/hosts file.

The example file is a community provided file that is many years old.

Can you explain more what you mean by "doesn't work"? What errors are you getting, what pages are you seeing? Is the problem that you can not resolve pihole.server.local or is the problem that you are not seeing the admin page but another page?