You didn't specify what league, or which game, or which rules you are playing, so the answer is in general terms.
In general, picking up the cue ball while still in motion is a foul. The penalty depends on the particular cue sport game you are playing and the rule set you are using.
In World Pool-Billiard Association rules:
6.6 Touched Ball
It is a foul to touch, move or change the path of any object ball except by the normal ball-to-ball contacts during shots. It is a foul to touch, move or change the path of the cue ball except when it is in hand or by the normal tip-to-ball forward stroke contact of a shot. The shooter is responsible for the equipment he controls at the table, such as chalk, bridges, clothing, his hair, parts of his body, and the cue ball when it is in hand, that may be involved in such fouls. If such a foul is accidental, it is a standard foul, but if it is intentional, it is 6.17 Unsportsmanlike Conduct.
Note item 2 below:
6.17 Unsportsmanlike Conduct
The normal penalty for unsportsmanlike conduct is the same as for a serious foul, but the referee may impose a penalty depending on his judgment of the conduct. Among other penalties possible are a warning; a standard-foul penalty, which will count as part of a three-foul sequence if applicable; a serious-foul penalty; loss of a rack, set or match; ejection from the competition possibly with forfeiture of all prizes, trophies and standings points.
Unsportsmanlike conduct is any intentional behavior that brings disrepute to the sport or which disrupts or changes the game to the extent that it cannot be played fairly. It includes
- distracting the opponent;
- changing the position of the balls in play other than by a shot;
- playing a shot by intentionally miscuing;
- continuing to play after a foul has been called or play has been suspended;
- practicing during a match;
- marking the table;
- delay of the game; and
- using equipment inappropriately.