mDNS would work just fine but the given command ('ping foo') wouldn't be using mDNS. That's just standard name resolution. `ping foo.local` would potentially use mDNS if you have a ping that does such a thing, but that's restricted to `.local` specifically.
Rather, most routers add DHCP hostname requests to the local DNS routes. That doesn't require mDNS, nor would you want to replace it with mDNS as mDNS is more limited & flakier.