'Heavens to Murgatroyd' is American in origin and dates from the mid 20th century. The expression was popularized by the cartoon character Snagglepuss - a regular on the Yogi Bear Show in the 1960s, and is a variant of the earlier 'heavens to Betsy'.
The first use of the phrase wasn't by Snagglepuss but comes from the 1944 film Meet the People. It was spoken by Bert Lahr, best remembered for his role as the Cowardly Lion in The Wizard of Oz. Snagglepuss's voice was patterned on Lahr's, along with the 'heavens to Murgatroyd' line. Daws Butler's vocal portrayal of the character was so accurate that when the cartoon was used to promote Kellogg Cereals, Lahr sued and made the company distance him from the campaign by giving a prominent credit to Butler.
As with Betsy, we have no idea who Murgatroyd was. The various spellings of the name - as Murgatroid, Mergatroyd or Mergatroid tend to suggest that it wasn't an actual surname. While it is doubtful that the writers of Meet The People (Sig Herzig and Fred Saidy) were referring to an actual person, they must have got the name from somewhere.
No fewer than ten of the characters in Gilbert and Sullivan's comic opera Ruddigore (1887) are baronets surnamed "Murgatroyd", eight of whom (or is that which?) are ghosts. Herzig and Saidy were well versed in the works of the musical theatre and that plethora of Murgatroyds would have been known to them.
Where then did the librettist Sir William Gilbert get the name? It seems that Murgatroyd has a long history as a family name in the English aristocracy. In his genealogy The Murgatroyds of Murgatroyd, Bill Murgatroyd states that, in 1371, a constable was appointed for the district of Warley in Yorkshire. He adopted the name of Johanus de Morgateroyde - literally John of Moor Gate Royde or 'the district leading to the moor'.
Whether the Murgatroyd name took that route from Yorkshire to Jellystone Park we can't be certain. Unless there's a Betsy Murgatroyd hiding in the archives, that's as close as we are likely to get to a derivation.