But Cambridge Dictionaries Online says it is informal.
And it appears on Urban Dictionary, which tends to signal something.
It wasn't originally, because it's from cock meaning rooster --proud as a rooster. However, I'm sure many people these days --particularly those who are younger --would associate it with a vulgarity (due to the fact that the use of the root word to mean rooster has been eclipsed by its vulgar use).
Just one of any number of terms whose associations have coarsened over time.
With regard to the OED's view of when cock acquired the meaning "penis," Eric Partridge, A Dictionary of Slang an Unconventional English, fifth edition (1963) has this comment in his entry for cock:
cock. The penis: 1730, says S[horter] O[xford] D[ictionary], but F[armer] & H[enley's example [in Slang and Its Analogues (1891)] from Beaumont & Fletcher's scabrous play, The Custom of the Country, seems valid. ...
Sulpicia. Shall I never see a lusty Man again?
Jaques. Faith Mistress/You do over-labour 'em when you have 'em,/And so dry-founder 'em, they cannot last.
Sulpicia. What's become of the Dane?
Jaques. Who? Goldy-locks? He's foul i'th' Touch-hole; and recoils again,/The main Spring's weaken'd that holds up his Cock,/He lies at the sign of the Sun, to be new breech'd.
This exchange suggests at least some level of popular awareness, in 1623, of a metaphorical connection between a male chicken and a male sexual organ.
UPDATE: However, an insightful comment from Erik Kowal casts considerable doubt on my equating of cock in the Beaumont & Fletcher play with a rooster rather than with a flintlock pistol:
Jaques's allusion seems to relate to a flintlock pistol or similar. He refers to many gun-related terms: the touch hole, recoil, the cock (a.k.a. hammer), the spring (against which the hammer is tensioned before firing), the ambiguous or suggestive use of breech'd. The chronology also fits: by the time the play was written, the flintlock was a familiar type of firearm.
That comment makes a strong case that the metaphor in The Custom of the Country involves a pistol, not a rooster. Farmer & Henley's only other pre-1730 citation is to Shakespeare's Henry V (1600), act 3, scene 1—[Pistol speaking:] "For I can take, and Pistol's cock is up,/And flashing fire will follow"—an instance that clearly refers to a pistol, not a rooster, and that Partridge doesn't endorse as metaphorical at all. In short, I went off to the rooster metaphor half-cocked.
A New Canting Dictionary (1725) includes a listing for "cock-sure" ("very sure") and also for various suggestive slang terms such as "cock-ale" ("pleasant Drink, said to be provocative"), cock-bawd ("a Man who follows that base Employment, of procuring; a Pimp"), "cockish" ("wanton, uppish, forward"), and "cock-pimp" ("a supposed Husband to a Bawd"); but there is no clear equating of "cock" with "penis" in any of these instances.
Charles Mackay, A Glossary of Obscure Words and Phrases in the Writings of Shakespeare and His Contemporaries (1887) offers this take on "cock-sure":
Cock-sure. Very sure, positively sure. In the first part of Henry IV.," Gadshill, in the Inn Yard at Rochester, says to the Chamberlain, who predicts the gallows for him, act ii. scene I,—
We steal as in a castle, cock-sure—we walk invisible.
Cock, in this compound word, has been variously explained by etymologists, the most commonly received root being "the cock of a gun," "as being," says Worcester, "much more sure of its aim than when fired with a match." Dr. Cobham Brewer, in his "Dictionary of Words and Phrases," inclines to the ornithological derivation, from the barn-door fowl—gallus. "Cock-sure," he says, "is cocky sure or pertly confident." "We call," he adds, "a self-confident, overbearing prig, a cocky fellow, from the barn-yard despot." Th true origin of the syllable is the Gaelic coc, manifest, plain, conspicuous; also to stick up, as in a "cocked hat," a hat stuck up on one side; cockade, a badge stuck upon a hat, and the Scottish phrases, "cock your bonnet" and "cock up your beaver." Whence cock-sure signifies manifestly sure, plainly sure, unmistakably sure; and Gadshill's reference to the castle from which he issued forth to steal, and to which he returned after his robbery was committed, simply implied that he was more than ordinarily sure—in the safety of his castle.
Francis Grose, A Classical Dictionary of the Vulgar Tongue, second edition (1788) adopts Worcester's view of the meaning of cock-sure:
COCK-SURE. Certain : a metaphor borrowed from the cock of a firelock, as being much more certain to fire than the match.
My impression has always been that cocksure refers specifically to the confidence with which a rooster announces sunrise, though the sun may still be some minutes away from making its appearance. Whether the original cock in cocksure was a rooster or the hammer of a pistol, I don't consider the term cocksure today to be informal or crude, despite its existing in a modern world where cock is often used extremely informally and crudely.