Scratching
when taken out of context can be a displacement behaviour. Displacement occurs when a dog is experiencing conflicting emotions and attempting to deflect stress, uncertainty, anxiety, or frustration.
What are calming signals?
https://www.silentconversations.com/what-are-calming-signals/