When my cats are working on a hairball that won't come up, they throw up whatever is in their stomach, so yes, it can be foamy if their stomach is empty, but it's food at whatever stage of digestion it's in if it's still present in the stomach when they start the retching.
Since you've been to the vet and they don't have any clue as to what it might be, if she were my cat I'd start treating her for chronic hairball problems and see if that helps.
A little bead of petroleum jelly a day is one option, or there are tons of cat-specific formulations that have flavoring. One of my cats does well with butter as a treatment, though I've read that's not supposed to work (it does on her though and she likes it much better than the vaseline).