With a thin sharp knife, make slits all over the surface of the ham.
Mash the garlic, salt, oregano, cumin, and pepper with the flat of a heavy knife on a cutting board. (Alternatively, use a small food processor or a mortar and pestle.) Scrape it into a small bowl and stir in the olive oil to make a coarse paste.
Rub the paste all over the outside of the meat, using the handle of a teaspoon or your fingers to force the paste into the slits. Put the meat into a large resealable plastic bag. Add the orange juice, lime juice, sherry, if using, and the onions. Refrigerate for at least 8 hours or up to 24.
Remove the pork from the bag and pour the marinade into a large roasting pan or Dutch oven. Spread the onions evenly on the bottom and lay the pork on top. Add 1/2 cup of water to the bottom of the pan. Cover tightly with a lid or heavy-duty foil.
When ready to cook, start the Traeger grill on Smoke with the lid open until the fire is established (4 to 5 minutes). Set the temperature to 300 degrees F and preheat, lid closed, for 10 to 15 minutes.
Roast the pork for 4 to 5 hours, or until the internal temperature is 170 degrees F when read on an instant-read meat thermometer. (If you want to shred or pull the pork, cook it until the internal temperature reaches 190 degrees F.) If the bottom of the pan begins to dry out, add more water or orange juice as needed. Do not let the juices scorch. Remove the lid or foil for the last hour of cooking if you want the skin to crisp.
Let the meat rest for 20 minutes before slicing or pulling. Spoon the onions and juices over the pork before serving.