The People of Gibraltar
1727 - The Duke of Wharton - Endowed with Every Quality 

Perhaps the first literary mention of the Duke of Wharton's exploits in Gibraltar comes from the diary of S.H - the anonymous British soldier who kept a record of his experiences during the 13th Siege of Gibraltar. ( see LINK
. . . the Conde de la Torres sent a present of some choice Fish to Admiral Wager, who gave them to the Governor and came to dine. . . .’ ‘Lt. Clarke of the Tiger, having been with a message to the Spanish General and had the honour to dine with the Duke of Wharton and Lady Mrs., brought a present of a whole wild boar and a large basket of fish from an officer to Colonel Anstruther. The fish proved to be bad, but the boar was dressed the next day.

The young Duke of Wharton

But perhaps the Duke deserves a longer mention. The 1860 publication - The Wits and Beaux of Society  by A.T Thomson  and Philip Wharton - includes what is tantamount to a complete and rather witty hatchet job on the 1st - and I suspect the last - Duke of Wharton.  The following are a series of quotes taken from the book.
Philip, son of the Marquis of Wharton, at that time only a baron, was born in the last year but one of the seventeenth century, and came into the world endowed with every quality which might have made a great man, if he had only added wisdom to them . . . . . The duke was not the man to be much ashamed of himself though his poor wife may now have begun to think her late mistress in the right, and he was probably glad of an excuse for another change. 
At this time, 1727, the Spaniards were determined to wrest Gibraltar from its English defenders, and were sending thither a powerful army under the command of Los Torres. The duke had tried many trades with more or less success, and now thought that a little military glory would tack on well to his highly honourable biography. At any rate there was novelty in the din of war, and for novelty he would go anywhere. It mattered little that he should fight against his own king and own countrymen: he was not half blackguard enough yet, he may have thought; he had played traitor for some time, he would now play rebel outright—the game was worth the candle.
His wife had once been a maid of honour to the Queen of Spain - which perhaps explains the ease with which he was able to contact 'Los Torres' - or Conde de las Torres - the man supposedly in charge of the Spanish forces aligned against the British during the destructive 13th Siege.
So what does my lord duke do but write a letter ( like the Chinese behind their mud-walls, he was always bold enough when well secured under the protection of the post, and was more absurd in ink even than in action) to the King of Spain, offering him his services as a volunteer against  'Gib.' Whether his Most Catholic Majesty thought him a traitor, a madman, or a devoted partisan of his own,  does not appear, for without waiting for an answer—waiting was always too dull work for Wharton—he and his wife set off for the camp before Gibraltar, introduced themselves to the Conde in command, were received with all the honour—let us say honour—due to a duke, and established themselves comfortably in the ranks of the enemy of England. 
But all the duke's hopes of prowess were blighted. He had good opportunities. The Conde de las Torres made him his aide-de-camp, and sent him daily into the trenches to see how matters went on. When a defence of a certain Spanish outwork was resolved upon the duke, from his rank, was chosen for the command. 

German print of the 13th Siege - the gentlemen discussing tactics in front of their tent may well have included both the Conde de las Torres and his aide-de-camp ( 1727 - Unknown )
Yet in the trenches he got no worse wound than a slight one on the foot from a splinter of a shell, and this he afterwards made an excuse for not fighting a duel with swords ; and as to the outwork, the English abandoned the attack, so that there was no glory to be found in the defence . .  . 
 . . . At the siege of Gibraltar, where he took up arms against his own king and country, he is said to have gone alone one night to the very walls of the town, and challenged the outpost. They asked him who he was, and when he replied, openly enough, 'The Duke of Wharton,' they actually allowed him to return without either firing on or capturing him. The story seems somewhat apocryphal, but it is quite possible that the English soldiers may have refrained from violence to a well-known madcap nobleman of their own nation.

The battleground of the 13th Siege of Gibraltar ( 1727 - Nicolas de Fer )
. . .  He soon grew weary of such inglorious and rather dirty work as visiting trenches before a stronghold; and well he might; for if there be one thing duller than another and less satisfactory, it must be digging a hole out of which to kill your brother mortals; and thinking he should amuse himself better at the court, he set off for Madrid. Here the king, by way of reward for his brilliant services in doing nothing, made him colonel-aggregate—whatever that may be- of an Irish regiment; a very poor aggregate, we should think. . . .

The Duke of Wharton ( E. Harding - from Pennant's Tour )