Take a look at this: Converting mouse position to Object coordinates
Once you identify the triangle that the ray intersects, you can collect the 3D coordinates and UVs of the triangle's vertices. With this information, you can calculate the UV position for the intersection point.
Here is some pseudo-code to help illustrate:
x0 = mouse.x; y0 = mouse.y;
vec3 samplePoint = unproject(x0, y0); // provides (x, y, near-plane-z) coordinates
ray.origin = camera.position;
ray.direction = samplePoint - camera.position;
var triangleComplexObj = check_for_intersections( scene, ray ); // identifies triangle, its vertices, their UV and 3D coordinates, and intersection point coordinates
calulateUV( triangleComplexObj , triangleComplexObj.intersectionPoint );
It may seem a bit intricate at first, but it should get the job done. I hope this explanation is helpful.