Well, it could work. But would it be the best solution?
One common argument I get when discussing this with people I know is that the costs of administering such a tax could be greater than the amount collected, and certainly if the tax wasn't set at a suitably meaningful amount to begin with, that could be true.
Just a few days ago I watched an interview of Robert Lustig on dietdoctor.com where they were discussing the subject of a sugar tax. He went to some lengths to emphasise that first and foremost, he is in favour of reducing sugar consumption regardless of how that might be accomplished.
I thought Lustig made a really good suggestion that would bypass the tax question altogether: cut the government subsidies that encourage such high levels of sugar production in the first place. All at once, you're simplifying the administration rather than adding to it, you're reducing supply through having reduced the incentive to produce it, you're increasing prices as a consequence of that reduced supply, and you're reducing consumption through higher prices. The same higher prices you'd get by imposing a tax upfront, except that now you're allowing market forces to play out across the board.
On this argument, Lustig was less inclined to favour a tax while Eenfeldt joked that he'd still be fine with it anyway.
But it was a really insightful discussion that served to remind me about what exactly what it is that we're trying to solve here, and that while the idea of a tax might seem to have some merit on the surface, we shouldn't discount the possibility that other ideas could be just as effective, if not more so.