There is lore for this.
Since this is a question of particular interest, I'm going to go ahead and give a broad overview of the lore we have on deities changing domains, and what we can take away from this.
If you'd like to save yourself a read, the TL;DR is: Help Desna beat up Lamashtu and rip the domain out of her by force (this will kill Lamashtu).
Of particular interest to you are...
- Irori attained godhood--and multiple domains--through a long quest of self-perfection and enlightenment. His nephew, Gruhastha, used a similar method when he achieved divinity by writing and merging with an exceptionally perfect and profound book.
- Nethys attained godhood by granting himself omniscience through incredible magical mastery. I've heard it theorized that he did this by devising a spell or ritual to merge his consciousness with the Akashic Records, but I don't have a source for this.
- Lao Shu Po ascended by eating a deity's corpse.
- The Iron Gods of Numeria are AI that ascended through "technological and supernatural" means.
- Nivi Rhombodazzle was granted godling status by Torag after she traded a special gem to him.
- Cayden Cailean became a deity by completing the Test of Starstone while drunk.
Among these pathfinder deities, we have some great examples of new domains being created. These can be broadly divided into categories:
- Embodying some concept with sufficient perfection and profoundness to be considered divine. (Irori, Gruhastha)
- Acquiring by magical mastery some sufficiently surpassing quality to be considered divine. (transcendental knowledge or awareness in the case of Nethys, and presumably transcendental power and intelligence in the case of the Iron Gods)
- Being granted a small amount of divinity from another deity or divine source, and then allowing your own domains to develop naturally based on your personality and history. (Nivi Rhombodazzle, Lao Shu Po, Cayden Cailean)
Lore examples of Deities changing domains...
Fortunately, we have the crucial example of Nocticula, whose domains changed from Chaos, Charm, Darkness, Evil to Artifice, Chaos, Darkness, Travel, Void due to an intentional decision to become good. This example is INCREDIBLY enlightening, as in her wiki entry, it took her a very long time to accomplish "leaving her demonic nature behind and becoming a full goddess" after she had decided to do so. She only managed it some time after accomplishing a Good deed of epic proportions: helping a group of adventurers close the Worldwound. In other words, merely deciding to change was not enough. Epic actions matching this change in character were necessary.
Of particular interest to you, Lamashtu gained a domain by killing the deity Curchanus in an ambush and taking it by force. Desna was given a single domain by Curchanus just before he succumbed to the physical and metaphysical injuries inflicted by Lamashtu. Similarly, Shelyn was given a single domain by the previous goddess of love upon her death. In other words, deities can give domains to others, either willingly or taken by force, but this process is lethal.
There is no evidence to support deities changing their domains through other means.
In fact, the best lore example of when this should have happened, when an entire city of Sarenrae's followers were corrupted by Rovagug during the Age of Anguish, during which they presumably offered her worship that completely misunderstood her core doctrines, had no effect whatsoever on her domains. Furthermore, Sarenrae's personality changed notably as a result of the experience, during which she "learnt a valuable lesson in espousing redemption over wrath". This also had no effect on her domains.
From these examples, we have two lore-based ways to change a deity's domains:
- Help that deity to accomplish deeds sufficiently epic as to trigger a change in her portfolio. (From Sarenrae and Nocticula, we know that merely changing how the deity feels about one or more topics is not enough, they must have epic deeds that exemplify this change!)
- Find an existing deity, or create a new deity with new domains, kill that deity, and give one of those domains to the deity or epic-level mortal of your choice. (To the best of my knowledge, we have no lore examples of a deity surviving losing a domain. We do have an example in Churchanus of a deity giving a second after being mortally wounded by losing the first, though!)
These two methods are the only lore-backed methods of changing a deity's domains that I am aware of.
Aside: Inspiration from DnD
While neither RAW nor lore, pathfinder's rules and lore are heavily inspired by DnD, which has some unofficial rules for ascension. In DnD, in order to become a deity, someone must first ascend by acquiring a divine spark, after which they are free to grow in power by acquiring increasing numbers of worshippers:
How does this apply to me?
In your specific case, Lamashtu and and Shelyn's examples give us a very clear answer as to how we can recover that beast domain for Desna: the very same way Lamashtu got it. By defeating the deity with superior numbers and tactics and then ripping the domain from their defeated form.
Since defeating a major deity is a rather difficult proposition, I recommend that the party, rather than killing Lamashtu themselves, track down Lamashtu's current location, lure her into an ambush, and help Desna (preferably with the assistance of several other deities) prevent the goddess from escaping while they beat her down.
Fortunately, Lamashtu has no allies, so there are no direct political repercussions to this act. The difficulty lies solely in convincing a force powerful enough to comfortably defeat a major deity to cooperate (relatively easy, as Good deities tend to have strong camraderie), devising a means to lure Lamashtu out of her lair or predicting the next time she will leave it in order to arrange an ambush (potentially harder), and preventing her from escaping after the ambush is sprung (the participating deities should be able to manage this, perhaps via the divine equivalent of grappling or Dimensional Lock).
I wish you all the best in your endeavors!