There is an evocative line in the description of the Fire Elemental:
Water can halt its destructive progress, causing the fire elemental to shrink back, hissing and smoking in pain and rage.
... but there's nothing about Water Elementals and lines of salt. Although that's nice and seems like reasonable lore (fits with a highly-elemental setting like the Codex Alera series), the actual thing in the rules is that freeze damage slows the elemental (but not very much, really). Likewise, the Earth Elemental doesn't have an opposed-element weakness, but rather is vulnerable to sonic damage — thunder. And Air Elementals aren't given any special vulnerabilities at all!
Overall, the 5E Elementals don't particularly have a pattern of counter-forces of the opposing element, or any sort of "rock-paper-scissors" thing where one beats the other. That might be a missed opportunity, but, eh, that's what it is.
Therefore, I don't think there's really a canonical, rules- or official-lore-based answer, because there's not a pattern to slot the homebrew monster into. It comes down to making up something which feels satisfying, and that's really up to you and your imagination.
D&D Beyond has a Homebrew Lightning Elemental, which suggests:
They, like true lightning, are drawn to objects made of metal.
... and you could take that as inspiration. This may be easier in an urban or steampunk setting than in a traditional high-fantasy one — you might need to set up something with a dwarven mining operation, ancient ruins, or a-wizard-did-it chunk of metal.
Or, for an alternate approach — in some fantasy settings, the counter or opposite to lightning/electricity is something nature or plant-based. In D&D, one particular monster that comes to mind is the Shambling Mound, which has:
Lightning Absorption. Whenever the shambling mound is subjected to lightning damage, it takes no damage and regains a number of hit points equal to the lightning damage dealt.
If you want a natural, wilderness setting, perhaps something could be done with that — although, this may be a case of trading one serious problem for another.
No matter what you pick, I think this will go better — and give your players more feeling of agency and involvement — if you set up the idea of opposing elements beforehand. Work out how the elements in your setting are related. If there is a "lightning elemental", is lightning itself an element? Is it part of air? Or are there energies associated with various elements? Maybe lightning is between water and air, and therefore opposed to lava (which is of course between earth and fire). Are wood and metal elements? And so on. Work all of this out, and then provide plenty of opportunities for your players to learn all of this beforehand, and perhaps see it in action (smaller elemental encounters before this big scene). In my experience, the general instinct of D&D players is to make a heroic battle against all odds, so if there's supposed to be an alternate solution, it's helpful to get everyone thinking in that way beforehand. (You don't need to lead them to the specific solution: just lay out that opposing elements may be a useful tool, and let them pick up the specifics.) I ran a game several years ago centered around elemental cults, and these details made it more fun for everyone.