Although trademark law explicitly allows for the possibility of registering the shape of a product as a trademark, in practice this almost always runs into problems.
2D or 3D design can be protected via a design registration. In design law, there is a strict rule: your design must be new and have an individual character. In general, design protection is no longer possible if you have made the design public before registration.
After years of controversy, coffee giant Nestlé also lost the battle for trademark rights of the shape of the famous Nespresso capsule in Switzerland.