Well, whoda thunk it?
In short, the word surly is no more than an alteration of sirly, which meant lordly, haughty, imperious, acting like a sir in fact. We can follow the development in OED.
[f. SIR n. + -LY1. Cf. SURLY a.]
Lordly, haughty, imperious
c1350 Will. Palerne 3316 Now William..stifli forth rides, so serreli thurth the cite al him-self one, that eche weigh was a-wondred. 1570 LEVINS Manip. 100 Serly, imperiosus. 1579 SPENSER Sheph. Cal. July 203 Sike syrlye shepheards han we none, They keepen all the path. 1600 HOLLAND Livy XXXV. xxxviii. 911 Syrly lords (say they) were the Macedonians, and rigorous. 1648 J. BEAUMONT Psyche XIX. i, Thine own erected head To far more solid Wretchedness doth bow Than ever made the vilest Reptile be The foot~stool of Contempt to sirly Thee.
[Altered spelling of SIRLY a.]
1. Lordly, majestic Obs., rare
1566 DRANT tr. Horace, Sat. I. ii. Bjb, How he doth decke, and dighte His surlye corps in rytche aray.
2. a. Masterful, imperious; haughty, arrogant, supercilious. Obs.
c1572 I. B. in Gascoigne Posies (1575), The sauerie sappes in Gascoignes Flowers that are,..Could not content the surly for their share, Ne cause them once to yeeld him thankes therefore. 1726 POPE Odyss. XXIII. 50 Stern as the surly lion o’er his prey.
3. a. Churlishly ill-humoured; rude and cross; ‘gloomily morose’ (J.). Said of persons (or animals), or their actions or attributes.
1670 RAY Prov. 208 As surly as a butchers dog. 1677 OTWAY Cheats of Scapin I. i, Thou art as surly as if thou really couldst do me no good. 1722 DE FOE Col. Jack (1840) 7 Captain Jack..a surly, ill-looked rough boy, had not a word in his mouth that savoured either of good manners, or good humour. 1757 SMOLLETT Reprisal I. i, Commend me to the blunt sincerity of the true surly British mastiff. 1770 GOLDSM. Des. Vill. 105 Nor surly porter stands in guilty state. 1807 CRABBE Par. Reg. III. 245 And surly beggars cursed the ever-bolted door. 1840 DICKENS Old C. Shop xvi, A surly, grumbling manner. 1865 KINGSLEY Herew. xix, A surly voice asked who was there. 1884 F. M. CRAWFORD Rom. Singer ix. I. 187 Dry throats make surly answers, as the proverb says.
Fascinating (and telling) shift in meaning!