The exchange quoted by Justice Scalia is most often attributed to F. E. Smith - although he was the kind of person, like Winston Churchill or Oscar Wilde, who tends to have things attributed to him. It's not clear that he actually said this, but it's certainly the kind of thing that people like to imagine he said. His general reputation and image is an intelligent and tenacious orator who achieved great career success at a young age, including being named King's Counsel less than a decade after being called to the Bar. So it is roughly in character that he would be associated with making clever and irreverent remarks to judges.
Even in England, where courtroom practices are different from the U.S.A. in several regards1, the quoted remarks are meant to be understood as unusually rude. We're meant to be amazed that Smith could get away with it, not take it as a model for how we ought to behave ourselves. I think the English tradition, especially a century ago, tends to value rhetorical cleverness and a certain amount of formal banter - where one can make jokes and allusions using "proper" courtroom language, while still advancing ones case. This comes across in other legal anecdotes which often feature witty ripostes, puns, and so on, usually taking place in open court.
In this tradition, the point is that barristers are meant to be very good at thinking on their feet, mastering a large corpus of detail, and working within the highly structured context of the trial; and specifically for the English, wit can signal high status as a kind of sprezzatura. By the same token, it is very easy to miss the mark, including by letting oneself slip over the line into actually insulting the judge.
Whether this remark would be taken as a "real" insult is quite contextual. I could imagine that (assuming this ever happened) the judge might understand it as being in the nature of playful banter, especially if the barrister went on to actually address the substance of the judge's criticism. Much would depend on the tone and on the history between the people involved. I could also imagine a judge being personally insulted but continuing to deal fairly with the case. What Justice Scalia is suggesting to the students is along the lines of "don't try this at home", as a fresh-faced young advocate is more likely to mess up their case (and potentially sour their relationship with the judge, people the judge talks to, their client, people their client talks to, etc.) than to achieve anything by the comeback.
1 What I'm gesturing at here is that while both kinds of court are formal affairs, the popular image of an American court is that it's full of people in expensive suits shouting "Objection! Badgering the witness!", and a British one is full of people in silly wigs murmuring "Uhhh, my Lord...?".