The altered scale can be used to play over dominant chords that have altered tensions (b9, #9,b5,b13). Most of the time that would be dominant chords that go to a minor chord.
The altered scale is the 7th mode of the melodic minor scale, so the G altered scale has the same notes as the Ab melodic minor scale. It is also relative to the lydian dominant scale (the 4th mode of the melodic minor scale).
altered scale = melodic minor scale up half a step
For example: the G altered scale = Ab melodic minor scale
|G altered scale||G Ab A# B Db Eb F|
|1 b9 #9 3 b5 b13 b7|
Here's the scale chart for G altered. The red dots are the roots. If you have troubles finding the other positions of this guitar scale, try the guitar scale finder.
Have a look at the following altered scale ideas:
In the following example I use 2 major triads that are found in the altered scale. In case of the G altered scale those triads are Db (Db F Ab) and Eb (Eb G Bb), so triads build on the b5 and the b13 of the altered scale:
I told you that the altered scale is mostly used on dominant chords going to minor chords. You can also use the altered scale on dominants going to major chords, just look out for a clash with the one who's doing the comping behind you (if he's good, he listens to you and plays altered tensions in his voicings).