Do the devas ever commit immoral actions? Or are they always morally perfect?
If they do sin, then in what manner do they sin?
There are many instances in many stories where Devas are shown doing immoral things because of Maya.
Sri Veda Vyasa said the Supreme personality of Godhead can keep the mighty demigods in his maya, or illusion. So he must have had the Devas in his maya.
I would like to illustrate one such story:
In the Uttara Kanda book of the Ramayana (regarded by most scholars as a later addition to the epic), Brahma crafts Ahalya as the most beautiful woman and places her in the care of Gautama until she reaches puberty. When that time arrives, the sage returns Ahalya to Brahma, who, impressed by Gautama's sexual restraint and asceticism, bestows her upon him. Indra, who believes that the best women are meant for him, resents Ahalya's marriage to the forest-dwelling ascetic. The Brahma Purana gives a similar account of Ahalya's birth and initial custody, recording that her marriage was determined through an open contest. Brahma declares that the first being to go around the three worlds (heaven, earth and the underworld) will win Ahalya. Indra uses his magical powers to complete the challenge, finally reaching Brahma and demanding the hand of Ahalya. However, the divine sage Narada tells Brahma that Gautama went around the three worlds before Indra. Narada explains that Gautama circumambulated the wish-bearing cow Surabhi while she gave birth, as part of his daily puja (ritual offering), making the cow equal to three worlds according to the Vedas. Brahma agrees and Ahalya marries Gautama, leaving Indra envious and infuriated. A similar, but shorter, version of Ahalya's early life appears in the Padma Purana In all versions of the tale, after marrying Gautama, Ahalya settles into his ashram (hermitage), which generally becomes the site of her epic curse. The Ramayana records that Gautama's ashram is in a forest (Mithila-upavana) near Mithila, where the couple practices asceticism together for several years. One Fine morning when the sage went to take the Holy bath, Indra disguised himself as Sage Gauthama and sexually abused Ahalya, later part of the story describes the purity of Rama which helped Ahalya gain her original form from being a stone.
Also in the story of Bhalichakravathy, Bhali took over the heaven because he was a ardent devotee of his Guru, the devas lost to him because they forgot their Guru Brihaspati
Also in The story of Govardhana, Indra would want to create floods as he wasn't satisfied with people worshipping him, Krishna suggested that one should always reflect the karma and should be worshipped and Later Indra realised he was under Maya
So The Supreme Personality of Godhead can keep anyone in Maya, So one must always think of him to successfully cross this Maya/ Illusion, So noone is committing sin on their own, It is the maya which creates such a situation, So remember God always
Jai Sri Krishna
If we translate/correct the term 'Sin' to 'Pāpa' then the answer is yes. Before we address this with scriptural reference, let's take an example in our present context. In order for us to get a continuous supply of electricity, coal has to be burnt non-stop. Coal is a natural and limited resource, and burning it releases a byproduct both solid and gaseous, such as nitrogen oxides, sulfur dioxide, carbon dioxide, ash, gypsum, and some heavy metals which are released into the planet's atmosphere. A similar analogy can be said towards making batteries and many household and commercial products too. But who takes these byproducts? The Planet does. In Scriptural terms, it's Mother Earth (Bhudevi). So, who is affected by it? All life and the planet as a whole.
So what is the point of this analogy? The point is, for something to arise, someone has to take a hit. As the saying goes, "if you want an omelet, some eggs have to be cracked".
How is this relevant to this question in a spiritual sense? If we explore the Vedas, especially the Brahmana section, we will notice countless exploits of Prajapati, who performs various actions to instigate creation and for Devas to emerge. Sometimes Prajapati performs Yajna, sometimes austerities, sometimes acts of Progeny, and many more. In many cases, there is always a by-product of this. For example, from the Tapo Dhuma (fumes of Tapas or severe austerity) arises anger in the form of Heat. So who takes the hit for this? Mānyu (Rudra), a cumulative form of Divinity emerges from this and manifests into something constructive. In another case, a nameless divinity arises as Bhutavan (Rudra) in Rig Veda consumes the Pāpa of Prajapati. In Sukla Yajur Veda Śatapatha Brāhmaṇa a nameless boy emerges from Prajāpati’s heat and expanded into 8 forms (natural phenomenons as bi-product).
Let's take more examples: Rudra is that aspect of Divinity that is cumulative in nature (A divine aspect of Vedas that overlaps/envelopes many other divinities), hence holds the mantel of being called Viṣvarūpam, Pururūpam, and Virūpam. As a result of this, this Vedic concept called Rudra manifests in the skies and in the sunlight, in the clouds and in rain, in lightning and in thunder, and in the event of Pāpa, becomes a tempest (violent storm). So, if we want to summarise this nature of Rudra, He/it is the "Vedic Enforcer or Punisher" towards the discipline, devotion, and scantily of the Yajamana (the one performing the Yajna). If a mistake or mishap happens (Pāpa), Rudra will emerge to consume it and gives back His wrath. This is why Rishi and the commoners feared Rudra, but they also reach out to Rudra as he is very benevolent. This is why Rudra is called Virupam, a Polar divinity who is not inclined toward someone (meaning doesn't have favoritism). This topic has many examples and the source is listed for those seeking intricate details with references, as this is only a summarized answer to a very generic question. Reference/Source: LINK