As others said, first, try to avoid meltdowns in the first place with well-planned touring (e.g., rope drop arrivals, good use of FP+) which will avoid time spent in line. Take frequent potty/snack breaks throughout the day, go back to the hotel for a long nap break in the afternoon, and make sure he's getting to bed at a reasonable time (preferably not much later than he typically goes to bed at home), so your little one is as well-rested and refreshed as possible while in the parks.
Also, in the case of a little one on their first visit, educating them as much as possible about what it will be like -- it will be hot sometimes, you'll have to wait for things, we'll be walking some long distances, not every attraction will be your favorite, etc. -- can help them adjust their expectations ahead of time. Giving him a little bit of say in the planning or touring now and then -- e.g., "shall we go to the Jungle Cruise next, or maybe the Tiki Room?" -- can also give him a sense of empowerment that can lessen the potential for his feeling frustrated. You can also show him park maps and/or Youtube videos of attractions ahead of time, in order to make his Disney experience feel a little less unfamiliar. Be sure that in all that preparation, you discuss with him your expectations of his behavior in the parks.
Second, if there is a meltdown, warn that if it doesn't stop you'll be leaving. Then if it continues, you scoop up your child (grandchild), ignoring looks and comments from any ill-mannered passerby, and leave. Take him back to the hotel for some quiet time, and sacrifice whatever plans you might have had for the rest of the morning (or afternoon, or evening, whenever the tantrum happens). It's not going to be fun for either of you, but follow-through is the only way to show a kid that he is not in charge, and hopefully save the rest of your vacation from similar incidents.
My husband and I had to do this a few times when our children were toddlers, and although it was no picnic at the time, it worked. Our children had to learn that we weren't going to permit them to ruin other peoples' enjoyment of public places by acting inappropriately, and that when we threatened to go home from somewhere fun if they couldn't behave appropriately there, we meant it.