One thing that can help is to put a thin mitten on when she goes to bed. Since she only does this in her sleep, and it makes her thumb hurt, she'll understand that this helps her thumb not to hurt when she wakes up, and should accept the mitten.
(Although be aware that she might be sucking her thumb during the day as well, just not when you see it. Thumbsuckers quickly get very good at hiding their thumbsucking from others :-) If this is the case it may be more difficult to get it to stop, but don't give up.)
There are substances that taste bad, made to stop biting your nails, etc. However I find that these tend to "spread" so that everything tastes bad, and you get kinda used to the taste after a while (didn't stop me from biting my nails). You can try them, but I suspect the mitten will be more efficient and less annoying for your child.