A dog may vomit yellow foam simply because his stomach is empty and the bile can be irritating.
If your dog is otherwise healthy and he's eating and defecating normally it may help to reduce the time in between meals.
Instead, one meal can be divided into two or three smaller but more frequent feedings.