Yes. Tension can vary if external forces are acting between the ends of the string - such as gravity (if the string has mass) and friction where the string makes contact with other objects (such as the pulley).
For example, suppose you attach one end A of a uniform massless string to a support and the other end C to a vertically hanging mass M. This creates uniform tension Mg in the string everywhere between A and C.
Now tie a mass m to point B on the string somewhere between A and C. Section BC is still supporting the same mass M, so the tension in section BC remains Mg. However, section AB is now supporting a mass M+m, so the tension in section AB increases to (M+m)g. AB and BC are still part of the same string, but the tension in each section differs.
Tension can also vary along a string which has non-zero mass and is being accelerated. Acceleration is equivalent to gravity.
In the illustration, the string is in contact with a pulley. Friction between the string and pulley opposes relative motion. This is similar to adding the weight at B between the ends of the string AC.