Yes, anxiety can cause bloating and gas. Gastrointestinal symptoms, such as bloating and gas, are common in anxiety. (Mussell et al., 2008). When you have stress and anxiety, your amygdala senses this and triggers the fight or flight response, where the sympathetic nervous system is activated and culminates in the release of adrenaline into the bloodstream. This results in your body becoming faster and stronger, so that you can either fight or flee from the danger.
So all of your body's resources are shifted from the reproductive system and gastrointestinal system to the essential systems for survival, such as the skeletal muscles and cardiovascular system. The changes in the gastrointestinal system cause multiple symptoms, including bloating/gas, belching, butterflies in the stomach (fluttery feeling), stomach pain, nausea/vomiting, lump in the throat, and nausea/vomiting.
Reference:
Gastrointestinal symptoms in primary care: prevalence and association with depression and anxiety. Mussell M, Kroenke K, Spitzer RL, Williams JB, Herzog W, Löwe B. J Psychosom Res. 2008 Jun;64(6):605-12.