Check with your DM
In addition to general rules for magic items and improvised weapons (which already point out that the DM may want to adjust), there are just a lot of case-by-case differences between magic weapons, so how this will work will depend both on the DM, and on the individual weapon. Because of this, there is no simple, single rules-based answer to this.
In additon, I think this is unlikely to be a practical problem you'll encounter in play. When you have a magical weapon, it is practially always preferable to use it as the weapon it is.1
General rules
The improvised weapon rules say:
An improvised weapon includes any object you can wield
in one or two hands, such as broken glass, a table leg, a
frying pan, a wagon wheel, or a dead goblin.
In many cases, an improvised weapon is similar to an actual weapon and can be treated as such.
An actual weapon is about as similar to an actual weapon as you can get. Normally, improvised weapons are not actual weapons that you misuse, they or other objects that you use as if they were a weapon. If you have an actual weapon, and you use it, it will be treated as such. If you on purpose use it wrong (like a net folded up, a sword taken by the scabbard to hit with the pommel), the DM may rule that it is treated differently.
The magic item rules would in principle allow to apply magical effects if the weapon is handled in this way, as long as you hold it. They only require that you hold the weapon to benefit:
Using a magic item's properties might mean wearing or wielding it. [...] A weapon must be held.
And you hold an improvised weapon. (At least, unless you opt to use it as an improvised ranged weapon and throw it, then you do not hold it; but a magical javelin still benefits from its magic enhancements when thrown, so the DM might decide that the magic properties stick, even if you throw it).
There also is an entry in the Sage Advice Compendium that gives an example where that you still get to benefit from the magical effect of magic items, even when you use them inappropriately:
Can you gain the magical bonus of a +2 shield if you are holding the shield without taking an action to don it? Yes, but only the magical +2, which you gain while holding the shield. In contrast, you gain the shield’s nonmagical AC bonus only if you use your action to don the shield as normal (see “Getting Into and Out of Armor” in chapter 5 of the Player’s Handbook).
If you use that as a reference, it suggests magic items would still have their special effects on hits, even when used inappropriately as an improvised weapon. At least there is no rule in the general magic item rules that says they would not. A +2 sword, if used as a club, should still deliver magical damage at +2 to hit and damage, as long as you hold it.
Case-by-case
That said, check with your DM. This may need to be dealt with on a case-by-case basis. For example, the arrow has this language:
If a creature belonging to the type, race, or group associated with an arrow of slaying takes damage from the arrow, the creature must make a DC 17 Constitution saving throw, taking an extra 6d10 piercing damage on a failed save, or half as much extra damage on a successful one
This does not specify the original damage needs to be piercing, but it at least implies it, by dealing extra piercing damage. The classical imagination for this arrow is the black arrow that was used to kill Smaug, the dragon in Tolkien's The Hobbit. If that arrow had not pierced the weak spot in Smaug's jewel-encrusted underbelly, it would have done squat to kill the dragon. Hitting Smaug with it like with a cane would have had no effect aport from you being eaten. And while such considerations are not rules, they can influence DMs who can rule as they think it makes sense.
Its similar for the vorpal sword:
When you attack a creature that has at least one head with this weapon and roll a 20 on the attack roll, you cut off one of the creature's heads. The creature dies if it can't survive without the lost head. A creature is immune to this effect if it is immune to slashing damage
And again, even though the item does not say so explicitly, the description implies you cut off the head with slashing damage. Otherwise, why would a creature with immunity to slashing damage be immune to the effect? Using the sword like a club wouldn't work.
P. S. Note that the vorpal sword requires attunement. The attunement rules in the DMG say (p. 138):
Without becoming attuned to an item that requires attunement, a creature gains only its nonmagical benefits, unless its description states otherwise.
So the vorpal sword would just work as a mundane sword unless you attune it. You can however also attune it, even if you do not plan to use it as a sword.
1 One exception I can think of is if you are proficient with improvised weapons (e.g. due to the Tavern Brawler feat), and find a magical weapon you are not proficient with. Then, using it as an improvised weapon with d4 damage may be more desirable than using it with its full damage, but no proficiency.