Heat butter in a large skillet over low heat until melted. Add onions, sugar, ½ teaspoon of the salt, and the water; bring to a boil. Cover and simmer until water has evaporated and the onions are fork-tender, about 20 to 30 minutes. Remove from heat and keep warm.
Sprinkle pork with pepper and remaining ½ teaspoon of salt. Spray a nonstick skillet with nonstick spray. Add pork and brown on both sides, about 5 minutes. Transfer to a small roasting pan.
Meanwhile, combine rosemary, garlic, and oil in a small bowl. Rub the mixture over the tenderloin. Roast until the pork reaches an internal temperature of 160°F, 15 to 20 minutes. Let stand 10 minutes before slicing into 1 inch slices. Spoon the onion jam over the pork.