I didn’t want to say “no,” because there is nothing about having a sword and shield in hand per se that prevents a character from spellcasting. But I didn’t want to say “yes,” because having a sword and shield in hand will, in most circumstances, prevent you from meeting the requirements to cast a spell. So, my vote is “let me explain...”
In order to cast a spell with verbal components, a spellcaster needs to be able to speak.
In order to cast a spell with somatic components, a spellcaster needs either a free hand or a spellcasting focus in at least one hand.
In order to cast a spell with material components, a spellcaster needs either a component pouch and a free hand, or a apellcastong focus in at least one hand.
A spellcaster wielding a weapon and a shield can perform the verbal components of spells with no issue, therefore they can easily cast spells like Thaumaturgy and Command, which have only verbal components. Somatic and Material components can be more complicated. Essentially, either the weapon or shield needs to be usable as a spellcasting focus, or the caster needs to be able to put one away. Since a cleric or Paladin can use a holy symbol as a spellcasting focus and a holy symbolcan Be emblazoned on a shield, they should have no trouble casting spells with material and/or somatic components, so long as they have a shield equipped with a holy symbol emblazoned on it. A Druid can use a wooden staff as a spellcasting focus, and likewise an Arcane caster can use a staff. Personally, I allow either to be used as a quarterstaff, so if that’s their weapon, they’re good to go. A Bladesinger Wizard can also use a sword they’re proficient with as a spellcasting focus, IIRC. Another option might be to keep a component pouch on hand and sheath your weapon (so you have a free hand to perform somatic components and interact with the material components) when you need to cast a spell. You only get one free object interaction on your turn though, so you couldn’t sheath, cast, and unsheath on the same turn.
I am also willing to accept spellcasting foci that are integrated into weapons or shields. For example, a crystal is a possible Arcane spellcasting focus, and if a holy symbol emblazoned onto a shield counts, then I see no reason a sword with a crystal in its pommel shouldn’t count as well. A cossguard on a traditional medieval European sword is meant specifically to resemble a cross, so I’m more than happy to accept other holy symbols worked into the hilts of swords. Heck, why not let a Druid have a scimitar specially made with a hilt designed to incorporate their totem while we’re at it?
So, I don’t disallow spellcasters to cast with sword and shield in hand, but not do I allow them to cast when they don’t meet all the requirements. Meeting all the requirements while wielding a sword and shield may require some special effort, such as using a particular weapon or commissioning a specially made weapon or shield that can also be used as a spellcastinh focus, but it is entirely possible for most characters.