The shape and design of a product can itself be protected by trademark law, under an area called trade dress.
Some famous examples of trade dress are the Levi’s jeans back pocket stitching, and the shape and color of certain pills.
Trade dress can be registered just like trademarks, but requires proof that the the design has acquired distinctiveness. Trade dress is also more vulnerable to challenge as being functional.
While the pitching on Levi jeans back pockets is entirely decorative, if that stitching lent structural support or reinforcement to the pocket, it would not be protectable by trade dress law.
Similarly, if a single medicine comes in several color coded pill dosages, those colors serve a functional purpose and may not be protected by trade dress.