Is there any way of predicting if ש is pronounced s or sh? Does it differ in different formation around the root?
They are different letters, not not grammatical representations of the same one (as in other cases, such as ב/בּ). To know which one it is you need to learn & practice.
That may be a useful way to think about it for language learning (which is why we're here), but your first sentence, at least, isn't true linguistically.
Usually, in modern hebrew, letters have little dots or stripes that mark different letters. Shin with a dot on the top right is pronounced Sh as in shalom. If the dot is on the top left, the letter is Sin and the sounds is S as in Israel.
Not after beginners and children, in regular media the shin and sin look the same, as do the other pairs... bet/vet pei/fei