It is a variation on the sweet martini, or Martinez, made distinctive by the Fernet-Branca, a bitter Italian digestivo.
[1] The hanky panky was the brainchild of Ada Coleman (known as "Coley") who began as a bartender at the Savoy Hotel in 1903.
[2] Her benefactor was Rupert D'Oyly Carte, a member of the family that first produced Gilbert and Sullivan operas in London and that built the Savoy Hotel.
When Rupert became chairman of the Savoy, Ada was given a position at the hotel's American Bar, where she eventually became the head bartender and made cocktails for the likes of Mark Twain, the Prince of Wales, Prince Wilhelm of Sweden, and Sir Charles Hawtrey.
Coleman told the story behind the creation of the hanky panky to England's The People newspaper in 1925: The late Charles Hawtrey ... was one of the best judges of cocktails that I knew.