You should be able to do that without problem.
With UR you can program relative to a point and you can offset the point with the information you get from the distance sensor.
By the way do you now that we have recently released a function could "Contact offset" which can relate and object by touch it and replace all waypoints accordingly ?
You can see an example in the following video (check from 0:23):
We have also possibility to locate a visual reference and relocate waypoint accordingly.
https://robotiq.com/products/wrist-camera
I would like to get the signal from the distance sensor through the Modbus and add this into the program which can steer the robot by offsetting the robot according to the surface plane