> What is wrong with this approach?

TL;DR You are forgetting that the kinetic energy is lost to the **perfect inelastic collision**. It can be shown from the *conservation of momentum* that in this particular example the total lost kinetic energy due to the collision is $K_\text{lost} = \frac{1}{2} M v^2$, where $M$ is mass of added sand.

----------

It does not matter whether the particle gained mass or velocity, the kinetic energy is always defined

$$K = \frac{1}{2} m v^2$$

The total work done must equal kinetic energy given to the added mass of sand plus kinetic energy lost due to the perfect inelastic collision

$$W = \frac{1}{2} M v^2 + K_\text{lost}$$

where $M$ is the total added mass of sand up until some point in time. You have correctly identified that $K_\text{lost} = \frac{1}{2} M v^2$ from the *conservation of energy*. We can also show that from the *conservation of momentum*

$$(m \cdot v) + (dm \cdot 0) = (m + dm) v'$$

where $m$ is mass of the cart plus sand added up until some point in time, $v$ is the cart velocity maintained at constant value by applying force $F = v \cdot dm/dt$, $dm$ is additional *infinitesimally small* mass of sand we put into the cart, and $v'$ is new velocity due to the perfect inelastic collision

$$v' = \frac{m}{m + dm} v$$

The lost kinetic energy due to the added mass of sand $dm$ is

$$dK = \frac{1}{2} m v^2 - \frac{1}{2} (m + dm) v'^2 = \frac{1}{2} m v^2 \frac{dm}{m + dm}$$

By rearranging the above equation we get

$$m \cdot dK + \underbrace{dm \cdot dK}_{\approx 0} = \frac{1}{2} m v^2 \cdot dm$$

We can neglect the product of two infinitesimally small values ($dm \cdot dK \approx 0$) which gives

$$dK = \frac{1}{2} v^2 \cdot dm$$

By integrating the above equation we finally get that the total energy lost in inelastic collision is

$$\boxed{K_\text{lost} = \frac{1}{2} M v^2}$$

and this exactly equals what you have already observed.