There are a couple of stories which link 'barking mad' with the east London suburb of Barking. One is that the phrase owes its origin to a mediaeval asylum for the insane which was part of Barking Abbey. The second story isn't a suggested origin, just a neat 1980s joke at the expense of Margaret Thatcher. She was known by those who disliked her as 'Daggers' Thatcher - not from a reputation for stabbing colleagues in the back, but because she was said to be 'three stops past Barking'. [Dagenham is three stations beyond Barking on the London Underground]
The problem with the asylum tale is the date - it is far too early. 'Barking mad' isn't mediaeval and began to appear in the language only around the beginning of the 20th century.
The first record of it that I can find in print is from the USA. The 11th November 1927 edition of the Oklahoma newspaper The Ada Evening News reported on the frenetic and, if contemporary photographs are to be believed, borderline insane sport of Auto-polo:
"At 2:30 this afternoon at Park field a half dozen barking mad auto polo cars will be whirled into action."
That usage suggests a readership who were already familiar with the phrase, and the playing of polo in cars, while having a strong claim to epitomise madness, isn't the likely source.
A much more prosaic derivation, that the phrase refers to mad and possibly rabid dogs, is a more probable source. There are many examples of 'barking like a mad dog' in print. For example, this from records of the trial for murder of a Walter Tricker, in 1867:
Mrs Hitchins, at the Inquest, says 'It was not ordinary barking. They [the dogs] were barking like tearing mad.'