Generally 'no', but many staves' descriptions specify 'yes'.
Three illustrative examples from the DMG:
Staff of Power: "This staff can be wielded as a magic quarterstaff that grants a +2 bonus...." (p.202) Typical +2 weapon, magical damage.
Staff of Charming: "The staff can also be used as a magic quarterstaff." (p.201) Clearly a magical weapon, but no pluses.
Staff of Fire: (p. 201) No mention of melee use. So the general rule on staves, from p.140 applies: "Unless a staff's description says otherwise, a staff can be used as a quarterstaff." So it can be used as a quarterstaff, but not as one that does magical damage (by omission).
(None of the DMG staves actually prohibit use as a quarterstaff, despite the general rule on p.140 contemplating this.)
I think they count as magical in three cases, but not in all others.
The berserker axe and hammer of thunderbolts (DMG), and another weapon from Hoard of the Dragon Queen, are always magical
For concreteness, let's look at the berserker axe, the first attunement-requiring weapon in the DMG. Its description reads, in part (DMG p. 155, emphasis mine):
You gain a +1 bonus to attack and damage rolls made with this magic weapon. In addition, while you are attuned to this weapon, your hit point maximum increases by 1 for each level you have attained.
Grammatically, it would seem that only the HP-benefit requires attunement, and that the +1 bonuses apply the moment you swing it. Then, by dint of having a magical +1 to attack and damage, I'd say the attack is magical and cuts through the shadow's resistance. (groan)
The hammer of thunderbolts also has this "severable" construction to its features, as does (HotDQ spoiler)
the greatsword Hazirawn, held by Wyrmspeaker Rezmir (HotDQ episode 8)
These two are definitely a close call, though. Perhaps even a toss-up.
In all other cases, the item only grants its nonmagical benefits
Most attunement-required weapons don't have this sort of provision, and it would seem that all of their magical utility requires attunement. See, for example, the holy avenger, flame tongue, staff of _____, sun blade, sword of _____, etc.
Further, the "Attunement" rules include the following statement (DMG, p. 138):
Without becoming attuned to an item that requires attunement a creature gains only its nonmagical benefits.
Certainly it looks like all of the other weapons, then, wouldn't give you their magical benefit without attunement. Moreover, the berserker axe does, in fact, require attunement, so this would seem to argue that you don't get any magical benefits from the axe. So perhaps even the berserker axe and hammer of thunderbolts need attunement to cut through resistance.
Best Answer
Only certain spells turn weapons magical.
The spell Magic Weapon specifies:
Likewise, the spell Elemental Weapon states:
If casting any spell on a weapon makes it a magic weapon, these spells wouldn't have to specify that they turn nonmagical weapons into magic weapons.
For an in-universe explanation, only spells that explicitly add magic to a weapon would affect whether a weapon was magical or not. Since spells like light or minor illusion don't deal damage on their own, and don't fundamentally modify whatever they're cast on, they don't add the magical quality to the weapon. Additionally, polymorphing a weapon only changes its physical form, and doesn't add any magical properties.
Developer intent supports this.
As Purple Monkey points out, Jeremy Crawford, the lead rules designer for 5e, confirms this: