There's a fairytale called Urikohime (瓜子姫, "melon princess"), where the titular tiny princess was devoured by an amanojaku. You can read it in a children book format or the full story. However, there is a version where the amanojaku kidnapped and raised her. This might be another basis for Shinmyoumaru.
Now we go to Kazuhiro Fujita's(most famous for the manga Ushio and Tora) currently running manga, Moonlight Act(月光条例, Gekkō Jōrei), which tells the various ghost stories and fairytales from East and West. One of its main characters who dealt with the Urikohime tale, wears a large bowl for a hat and dresses pretty much like Shinmyoumaru.
Well, knowing ZUN, this might actually be the source of his idea. This may even be worthy to be put on the wiki.
With that, this can be when she first met Sukuna or after she entered the Myouren temple and repent. Edit: The artist confirmed that it was their first meeting.