Depends. The SBB (federal rail) and most local rail services allow sandwiches, fruit, bottled drinks, cups with lids and that kind of stuff. There's nothing about food limitations written on their code of conduct website but I've seen their personnel berate people for eating McDonald's. Long distance trains usually have a restaurant wagon in the middle (then again, "long distance" for Switzerland is like 2 hours). Buses and coaches usually won't allow anything except bottled water.  Source: am Swiss.