A tax is a disincentive, not a restriction of freedom. As in, if you want that sugar, you will pay extra for it due to the increased strain on the healthcare system you likely will add to down the line. You can still consume as much as you want at the end of the day.
By removing options from people you take responsibility from individuals. Do you stop on red because of possible fine or danger from collison with other vehicle?
If it turns out that there is no increased strain on the healthcare system (because, for example, people who consume a lot of sugar die younger and so don't require as much old-age care), would you then advocate removing the disincentive?
This is way over-simplified. Dying young does not mean that they don’t need expensive invasive treatment before they do, possibly for a couple of decades. It’s also a completely inhumane way of looking at these problems.