In the sense of “a goblin or spirit,” first recorded in 1685–95.
In the highlighted sense, first recorded in 1955–60.
Comes from Spanish and is shortened from duen de (casa), “master of (the house)” with duen a variant of dueño, meaning “lord; owner” from Latin dominus “to control.”