As I learned it in my linguistics undergrad, the usage is systematic. Your best bet to cover most cases is to pronounce it [y] in open syllables and [ʏ] in closed syllables.
In European French, this sound is always [y] — at least nominally.
However, in every dialect of French, there is a tense/lax realization of certain vowels, where the tense variant appears in an open syllable and the lax version in a closed syllable.
This rule can't be applied universally since some high vowels lack lax variants in European French: /i/, /u/, and /y/. But in Québec, these vowels do have lax variants: [ɪ], [ʊ], and [ʏ] respectively.
The rule is the same for these pairs as for others:
ici [i] vs. icitte [ɪ] *
roue [u] vs. route [ʊ]
du [y] vs. chute [ʏ]
As the Wikipedia article jlliagre shared says, a lax vowel in a closed syllable can also harmonize a nearby tense vowel, e.g. [ɪ] in musique harmonizing [y] to [ʏ]. (This effect is less predictable.)
* An undergrad paper I wrote hypothesizes that innovative forms like icitte and frette, whose origins are hard to identify, could have co-evolved with these lax vowels, as if to produce more occasions to use them and thereby further differentiate Québécois French for sociolinguistic reasons. Take that for what you will. :)