You can see this working in the forest scene when Pearl, an ambiguous character herself, interacts with the sunlight and the shadow. Hawthorne used a great deal of this light/darkness imagery in many of his stories. You might want to refer to "Young Goodman Brown" to see it working in a similar fashion.
Throughout the novel, light is connected with revealed truth, whereas darkness or shadows are connected with hidden truth. The truth of Hester's sin is revealed on the open scaffold in broad daylight; the true nature of Pearl is revealed as she plays by the brook in the sunlight, while Hester and Dimmesdale talk in secret in the shadows of the woods. The sun shining during Dimmesdale's sermon is also connected to revealed truth. More specifically, it is foreshadowing the coming confession of Dimmesdale upon the scaffold.