It is possible.
The most straightforward way would be to push the x/y coordinates of the input every tick into an array. To replay, just go through the array and draw from each saved coordinate instead of the mouse/touch input.
I don't know if there would be performance issues without trying. You can trade resolution/accuracy for performance by adjusting how often you save a set of coordinates.