Hi Peter, you are more than welcome to bring your own food on the train. Most train stations sell cute and delicious bento boxes to bring on the train.
Green cars usually provide food services, but they can only be used with a “Green Pass”.
Order your green japan rail pass here: Green Japan Rail Pass • Japan Rail Pass (getjrpass.com)
There are however some vending machines for warm and cold dricks and easier snacks on many of the trains and many of the long-distance trains have food carts.
With kind regards, Jonathan H.