Vending machines do seem like a good solution. Obviously the experience in other countries (which of course the British industry will steadfastly refuse to draw upon, as per usual) proves that the potential food hygiene issues are not insurmountable. Many trains that currently have pathetic (and disruptive; I've more than once had the trolley cut me off from my luggage when attempting to disembark) trolley services also have disused shop/buffet areas, so replacing those with vending machines wouldn't cost any passenger space.
For a country that has invented so much, it is always strange when we are so against some things that other countries have already demonstrated works, or can work.
We now have London installing lower down lights for bikes. Something I saw in Sweden 30 or 35 years ago. We made a big fuss over the pedestrian 'X' crossing at Oxford Circus, even though you could have seen that in Japan decades ago.. Oh, and the countdown timer on crossings was the same.. TfL deciding to do extensive testing, as if all the countries around the world had somehow not noticed any potential flaws and we were going to do so.
I get the argument that a vending machine takes up luggage/seating space, but that's about the only reason I can think of to be against them - and it wouldn't apply to every single bit of rolling stock.
Vending machines at stations, often the only way to get a can of drink or chocolate bar, don't seem to be regularly cleaned. Someone comes along every now and then and restocks them and takes the money.
It might be different for fresh sandwiches or hot drinks, but I would have thought water, coke, lemonade and some confectionery would work. Make them take cards only (including contactless, Android/Apple Pay etc of course) and you do away with a major security concern.
You could even have a barcode reader so that a TOC could offer a complimentary selection to some passengers, either perhaps travelling first class or as a loyalty reward. The good thing about that is you give a voucher, and if the machine is empty or out of service the voucher can be used another time.