Its body disintegrates and a lower-ranking modron evolves to take its place.
In D&D 5th edition, destroyed monodrones are simply replaced with newly-built ones, and higher-ranking modrons are replaced by promotion of lower-ranking ones (Monster Manual, p. 224):
If a modron is destroyed, its remains disintegrate. A replacement from the next lowest rank then transforms in a flash of light, gaining the physical form of its new rank. The promoted modron is replaced by one of its underlings in the same manner, all the way to the lowest levels of the hierarchy. There, a new modron is created by Primus, with a steady stream of monodrones leaving the Great Modron Cathedral on Mechanus as a result.
It's not clear whether modrons have a soul. They are constructs, machines. They are built, not born. However, in an earlier edition of the game, they are defined as living constructs, a type of construct which is sentient, can have free will, and can be raised or resurrected, suggesting they may have a soul. (Return of the Modrons, Dragon Magazine #354, p.35-49.)
There is some lore which suggests that their life energy could be trapped in that plane. In Return of the Modrons, p. 41, it states:
Ondrild, a now deceased wizard who studied modrons extensively, found through complex experimentation that destroyed modrons send their life energy back to the Energy Pool, and that each advancing modron subtly draws upon the pool to power its transformation.
Ondrild believed he was close to discovering how the energy transfers (even between planes) when he was found murdered and his laboratory destroyed. It was no surprise to Ondrild's students that the killers apparently destroyed the lab in a very thorough and orderly manner. None of them carried on his research in modrons after that.
Hence, a modron's life energy returns to the Energy Pool from which Primus creates all new modrons, but the exact mechanism by which the energy returns is canonically a mystery. It's therefore unclear whether a destroyed modron's energy can escape Barovia, but this does not seem to prevent the creation of the modron's replacement. Since Primus controls all modrons (with some exceptions), it is unlikely that he would intentionally send enough modrons into Barovia to drain the Energy Pool to the point where new modrons cannot be created.