Yes, a relative clause can modify a whole sentence.
"The cake was burned, which made me angry." (English relative clauses # Overview - 10th item in the list)
Strictly speaking, cake is the head noun of the noun phrase, which is modified: "The burned cake made me angry."
Analytic interpretation gives the preceding phrase "was burned" is to be modified by the relative clause, though, and clearly, the burn (or burning for friends of the gerund) is the culprit, the cake's burn, to be specific, so we could say: "the cake burn made me angry". Now, because the interpretations are equal in meaning, we just say the whole sentence is modified, for simplicities sake. And rightfully so, because "is" marks an equality.
(Edit: In that sense "which" indeed modified the whole phrase. Because of the equivalence relation "to be", each noun entails the other. This equivalence is "envied".)
The comma is a different issue. It is needed, because the relative clause is non-restrictive (see at the link given above). In another interpretation which is my own opinion the comma is needed precisely to signal the whole phrase as referent.