No, it isn't illegal. The retailers and manufacturers justify it because a larger dress uses more material; there are less made in a single large size (eg 20) than a single standard size (eg 12) so each unit costs more; a batch of larger dresses weigh more so transport costs are higher; they took up more room in storage....
Some retailers have used this practice for many, many years.
Why should it be against the law? I pay more for a 10 ounce steak than an 8 ounce steak.