I managed to make it work as you described but only with one VPN provider: ProtonVPN. If your VPN app proposes split tunnelling with exclusion based on IP, it should also work. This solution however doesn't use the package name (solution you suggested in your question). I hope it will still help...
The workaround is as follow:
- Switch on your Chromecast (needed for step 2);
- Identify the IP address of your Chromecast. The simplest way I found to do that is to log in to the router as an admin (192.168.1.1, don't forget to disconnect your VPN on the device you are using to access that address ;) ). There you will be able to find the list of the devices currently connected to the WiFi. Spot the Chromecast and the associated IP address (192.168.1.*);
- Go the settings of your VPN Android app and check for the split tunnelling feature. You will need to be disconnected from the VPN to change this setting.
- Add the Chromecast IP to the "Excluded IP addresses"
Now your VPN app will connect directly to the Chromecast when needed. Surprisingly (to me) I didn't need to add the Google Home app or the app that I'm casting to the excluded app list.
I guess that if you restart your router (some of them do that regurlarly by themeselves for update purpose) the IP associated to the Chromecast might change and you will need to re-do the operation. However switching off then on the Chromecast (with power supply interuption in the meantime) does not change the IP address of the Chromecast.
If somebody knows a way to add all the local addresses easily, please share it ;)
Source of the idea: https://www.reddit.com/r/ProtonVPN/comments/9riylh/chromecast_while_on_protonvpn/