This is entirely up to the DM.
MM 9 (sidebar Armor, Weapon, and Tool Proficiencies):
Assume that a creature is proficient with its armor, weapons, and tools. If you swap them out, you decide whether the creature is proficient with its new equipment.
As noted in the comments, the only wrinkle here is attunement. If the weapon requires attunement to unlock certain properties, the monster cannot use those properties for the attack. A Holy Avenger, for example, would just be a regular sword, but a Dagger of Venom would function normally.
As for Multiattack: in cases where it specifies a weapon (e.g. Oni :"...two attacks, either with its claws or its glaive"), RAW would indicate that it cannot use different weapons for Multiattack (and could only instead take the Attack action, making 1 attack). Other monsters (e.g. Cult Fanatic: "two melee weapon attacks") could use Multiattack with any melee weapon they happened to be using.
As for me, I'd likely say that any decently-intelligent humanoid (such as the Bandit Captain in the example) can use any proficient weapon of the same category (ie melee vs ranged) for Multiattack. But that's my personal ruling, not RAW.