What you are looking for is to transform a location value into a rotation value, and this is exactly what math functions arc sin and arc cos do.
In my example I used an Armature with bones, but you can use Empties as well.
Set the desired rotation to happen on X axis, right click on the X rotation value and choose "Add Driver".
In the Driver editor page set the variable to measure a distance, and set the distance objects (Base and Controller).
Now set the driver Type to Scripted Expression and type the expression " -asin(var/2)", where the number 2 is the desired lenght of the half of the table.
As it's important to stay between allowed values, I set a Limit location constraint on Controller bone, going from 0 to 2, and a copy rotation constraint from Side.L to Side.R.
