Many of my guests are surprised at how people behave on trains in Japan. No eating, no drinking, very VERY quiet, almost complete silence. People are either sleeping or looking down their iPhone. And the answer to the question depends on the situation. If you have something that creates big noise and strong smell on a crowded train, that is definitely a big no no but when it's a piece of chocolate or candy, it's fine. I sometimes see someone eating onigiri rice balls for breakfast on a rather empty train very early in the morning. I personally think it's ok as far as they don't make big noise or smell but I wouldn't do that myself because some people may not think it's ok. There is no sign that says "no eating/no drinking" but people just care about others and try not to make other people uncomfortable. So the best you can do is, don't do when you are not sure !
By the way, this unwritten "no eating/no drinking" rule only applies to local trains. I will write about the rule on Shinkansen bullet trains some other day !