I was looking for this as well, but you can actually do it, just not Quite in the same way, and it's Way too much work. I'm writting a request to just open this up in nodes instead, but wanted to see if there was another way to do it.
So add the driver to the viewport display.
Create an rgb node. Right click and copy the full path (you'll only use half of it)...
@Isolin's way seems much more in the spirit.. but here goes with a follow-up of @Gorgious' comment. This just gets a random-per-array-element attribute on to all the array-object's vertices.
Setting a U offset of 1 in the Array modifier
flooring the split-out U of the 'UV Map' attribute gives you an index per array element, on all vertices
That index can be ...
I was able to find a way! There is a mesh primitive node called Line. I can use it as a 1D array. Unfortunately I didn't find a way how to convert a float to an integer to feed its count slot, so I switched to end points combined with resolution.
I can also easily extract the index property from the line vertices, just by using an attribute separate xyz of ...
You don't need drivers if you're using a more recent version.
You can directly access object custom properties in the Shader Editor, using the Attribute node. Set the Type to Object and type out the name of your attribute.
Have an object with a color custom attribute named color and a float attribute named roughness.
Using 2 attributes node in the ...
Look at the value of the driven property.
In the example given in question, the bevel modifier width of one cube is being driven by that of another. Have set up similar, the driver value being displayed via UI is 0.2
Given the object of interest has context, retrieve this value by simply
>>> bm = C.object.modifiers['Bevel']