This could be possible, providing you have the right dataset to train it on.
The volume of a cup consist of width, height and depth. You can probably detect all three of those given the bounding box or the pixels of the cup. However detecting the dimensions of an object require a reference object, like a penny or your finger and you have to specify the exact dimension of that. If that method fits your problem which I assume not, this is a good resource to look through: Open CV measuring dimensions
However to do the task, you need a way to measure the volume without the reference object. To fo this you need a deep learning based approach. Depth detection using fully residual convolutional neural network maybe a good start for your project as you are doing something similar. You may use one of the pretrained model and apply transfer learning on it with the image of the cup and the surroundings, and get the output and feed it through another feed forward neural network to predict the volume.