#It's a DM call
This is a case of rules vs rulings. Let's start by defining a few terms that don't have game definitions.
Polymorph: To transform; to change into another form.
Resemble: to be like or similar to.
Now when we look at the Imp's Shapechange ability, we can substitute these definitions:
The imp can use its action to transform into a beast form that is similar to a rat, crow, or spider [...]
The extent of the transformation and the similarity between the forms is not defined, nor is the form's ability to speak, either magically or anatomically.
A DM could assume the form is an exact match for the beast, then easily look at the spell polymorph and other similar abilities like Wild Shape, and determine that the imp's ability to speak is prevented by it's new form. On the converse, a DM could assume the form simply grows the necessary limbs and appendages to replicate the new form's movement options, leaving it's mouth and ability to speak entirely intact. Furthermore, some DM's might call for a total transformation into a beast, but due to an explicit lack of rule that says the new form can't speak, allow it to anyways, regardless of any anatomical inability.