A conceptual approach might work better, since the shaking system is not going to convert mechanical energy into thermal energy as neatly as something like Joule's Paddle Wheel. As the bottle is shaken, the liquid in it is swirled around into more or less randomly oriented vortices. These cancel one another out and slow to rest via friction with their container, and the energy they contained has to go somewhere. As you wrote, it winds up increasing the average velocity, and thereby temperature, of the particles in the milk.
This basic mechanical to thermal energy conversion is the source of the conversion factor from joules to calories. Joules are used to measure mechanical energy and calories were used to measure thermal energy. It was the paddle wheel experiment I linked above that first related the two to one another.
The challenge presented by trying to relate the work done on the bottle of milk to the thermal energy that winds up going into the milk is less mathematical than practical. On any given shake we would first put energy into the bottle (move it upward, let's say) then take energy back out (slow it to a stop) before putting energy back into the bottle (moving back downward) and taking energy out again (slowing to a stop a second time.) This repeats until we get tired of shaking, and if we measured the difference in all of the energy inputs and outputs that ought to equal the thermal energy added to the milk, but actually doing that for real would be a pain.