Absolutely, But not as simple as taking a return value of a normal function.
First I assume your question isn't about sharing variables between two shader stages (vertex, fragment..etc) but actually between two shader (programs).
Shaders are part of the rendering pipeline, every input/output should pass through the rendering pipeline and its memory is allocated on the GPU.
Regardless of each APIs terminology, you need to write to an intermediate buffer and pass that buffer to the next shader program. A widely used technique is to render to a texture and pass the texture into the next shader. Most of the advanced effects are implemented using a variation of this technique most; notably all of the deferred renders use this to generate of what is called a G-Buffer that contains several info about the geometry in the scene (Position, Normals, Tangents) all those are output of the geometry pass of the deffered render and encoded in buffer.
This G-Buffer is read by the deffered lighting stage, where all the values are read from the G-Buffer to perform what ever lighting calculations you need to perform. Other notable effects include reflections, where geometry is rendered for an offscreen buffer, and then assigned as texture with usually generated texCoords on the reflectors.