In The Hunchback of Notre Dame, Frollo relates a story that supposedly Averroes buried light in order to create gold from it, as, according to him, gold is light, but that it would not be for thousands of more years until the process would be complete:
"What! this light which inundates my hand is gold! These same atoms dilated in accordance with a certain law need only be condensed in accordance with another law. How is it to be done? Some have fancied by burying a ray of sunlight, Averroes, - yes, 'tis Averroes, - Averroes buried one under the first pillar on the left of the sanctuary of the Koran, in the grand mosque of Cordova; but the vault was not to be opened, to see whether the operation had succeeded, under eight thousand years."
Is there any basis of truth, or even precedent, to any of this?
Alchemy was a "living subject" in Islamic science and philosophy.
See at least Lawrence Principe, The Secrets of Alchemy (2013, The University of Chicago Press), Ch.2 Arabic al-Kimyia.
A central thinker was Jabir ibn Hayyan (Latin: Geber). Also al-Razi with the Book of Secrets and the refutation of al-Kindi's denial of the validity of alchemy.
Ibn Sina (Avicenna), in turn, in the Book of the Remedy denies the possibility of metallic transmutation.
Also al-Baghdadi was profoundly averse to alchemy.
I've found no reference to Ibn Rushd (Averroes) interest into alchemy.
Having said that, a possible conclusion may be the following: it is reasonable to assume that Victor Hugo had no detailed knowledge about Islamic science.
Thus, a "generic" knowledge about Arabic and Middle Ages interest into alchemy, as well as the common (in Hugo times) view about the "dark ages", may explain Hugo's story.
The attribution to Averroes is probably due to the fact that Averroes'name was (one of) the "best known".