How to make all volumes use local driver or specify custom name for volume in docker-compose.yml

Not with docker compose alone. You would need your own template engine to generate a compose file that already generates the compose file you want to use. Here is a makefile example for how this could look like with envsubst: Data directory "/var/lib/postgresql/data" has wrong ownership... on Linux? - #10 by meyay.

Though, what’s wrong with having fixed names in your compose file? The project name for the deployment will be prefixed to the volume name on the host. You could use a fixed name like myvolume and deploy your compose project with docker compose --project-name a up -d and get the volume a_myvolume, then deploy the same compose file with another project name like docker compose --project-name b up -d and would get the volume name b_myvolume. Inside the compose file the reference would remain myvolume in both cases.