Yes anxiety can cause you to wake up gasping for air.
When you have anxiety and suffer a panic attack during the night it can cause you to wake up in the middle of the night and have trouble breathing.
Gasping for air when you have anxiety and a panic attack is normal and it's usually nothing to worry about unless it gets worse.
The best thing you can do is just try to calm down and if possible breathe into a paper bag which helps some people.
If you do feel like you're actually having trouble breathing then call 911 just to be safe.
Although most times the panic attack will go away and you'll start breathing normally within a few minutes of calming down and relaxing.