Targaryens didn’t practice polygamy at the time of Jon’s birth/conception though. Jon’s going to be considered a bastard by most regardless.
Polygamy stopped being accepted for Targaryens by the people after the dragons died out. Rhaegar was already married to Elia, whether or not he also attempted to marry Lyanna would not stop people from declaring Jon illegitimate as second wives weren’t acknowledged at the time.
GRRM: Maegor the Cruel has multiple wives, from lines outside his own, so there was and is precedent. However, the extent to which the Targaryen kings could defy convention, the Faith, and the opinions of the other lords decreased markedly after they no longer had dragons. If you have a dragon, you can have as many wives as you want, and people are less likely to object [source]
Polygamy was never actually accepted by the Faith and Westerosi lords really. Early on, when dragons were still alive, no one could really do anything about it. Doesn’t mean it was accepted, just that people didn’t have a say. At Rhaegar’s time (about 127 years after the dragons died out,) he couldn’t have had a second wife. It wouldn’t have been accepted- the slight to Elia, it’s anti-Westerosi culture and customs, ect. Of course, Rhaegar made some incredibly poor political choices at this time in his life and didn’t do anything to mitigate the slights to Elia that he caused anyway.
Regardless, whether or not Rhaegar “married” Lyanna doesn’t really matter since people who would be opposed to Jon as a Targaryen have no reason to accept that marriage as valid. In the eyes of Westerosi culture, Rhaegar and Lyanna couldn’t have gotten married as he was already married to Elia. So really it’s mostly irrelevant.
Jon will be considered a bastard by everyone who wants to see him that way. Just like how if Stannis had legitimized Jon, anyone who didn’t want Jon to be seen as legitimate would say it didn’t matter because Stannis wasn’t actually a king and didn’t have the power to do so. Same thing could be said about Robb legitimizing Jon in his will as there are a lot of people who reject the idea of being a king.
And then isn’t that like Robb declaring himself king? Many opposed it, many followed him. Some viewed him as a king while others considered him an usurper. Legality in Westeros can easily become whoever has the power to make people accept what they want.