For a give fluid of varying composition, like urine, refractive index and specific gravity are closely correlated. Clinical labs, for example, usually measure the refractive index of urine, but report the result as the specific gravity.
Automated refractive index instruments are readily available, handheld, and probably cheaper because of their widespread use. You might even get an older unit from a clinical lab for free.
Have you considered refractive index instead of specific gravity? Will it work for beer?
As for specific gravity per se, I would consider a capacitive sensor to detect the float level instead of light.
John