If your going to use a beer gun, I hate mine, you need that horribly long tube and both the bottles and the beer must be COLD.
If you don't use the tube and/or your bottles and beer isn't cold then the foaming is inevitable.
Get the beer down to say 5°C, put the bottles in the freezer and...