It seems almost certain that "dude" derived from "doodle," as in "Yankee Doodle Dandy." The original New England Yankee Doodle, Cohen notes, 'was the country bumpkin who stuck a feather in his cap and called it macaroni; i.e., by sticking a feather in his cap, he imagined himself to be fashionable like the young men of his day known as "macaronis."
For some reason, early in 1883, this inspired someone to call foppish young men of New York City “doods,” with the alternate spelling “dudes” soon becoming the norm.
Dude! by Allan Metcalf