Photoshop can make simple 3D extrusions and a few preset shapes such as sphere or bottle. No general 3D modelling tools exist, you need a 3D program if arbitary forms are needed. You can create a well adjustable 3D shape from text by using the Repousse effect (assuming your Photoshop is not older than 10 years).
See the original Photoshop User's guide or search for tutorials for 3D Repousse and general 3D properties of Photoshop.
You must have your molded shape photo as a reference and find by trial and error how to rotate and scale the extruded text and how to set lights and perspective. You have good possiblities to succeed if your molded shape has nearly planar surface with no complex texture.
The fundamental idea is that you make a new layer to your photo with 3D tools. If the new layer is grey it takes its color from the underlying photo if you use layer blending mode Hard Light. You can adjust with curves the brightness and contrast of the new layer.
It is well possible that you must make a drop shadow for the logo shape to make the light look right.
Changing the color is no problem if your molded piece has only one color. You can make all at first BW and recolorize assuming you have learned how to remove the background with high quality.
Here's an example. The "molded piece"is only a screenshot from a 3D drawing program. Forgive me the not so realistic rendering, its from entry level freeware which has no advanced tools.
A piece of text is written onto a new layer. It has got 3D Repousse effect. The light and the viewing angle are tweaked some time. The text is originally 50% grey but it has light which comes approximately from the right direction. There's no attempt to match the perspective.
The blending mode of the extruded text is changed to hard light, the opacity of the layer is reduced, the only light in use is changed to pink to avoid too washed highlight and the shadows of the text are a lifted with the Curves adjustment layer:
The adjustment layer has "the next layer only" switch ON.
Rasterizing the text layer (after rendering with good quality) makes possible to distort a little the geometry for better fit to the perspective of the photo. The text can be more readable as a little washed although its theoretically wrong in this case. The color saturation is reduced with Image > Adjustments > Hue&Saturation.
As said earlier, a drop shadow can be useful. Usually they are used to create an illusion of levitating objects but in this case the purpose is the opposite. The shadow is not an effect, it's a black blurred copy of the text, the part hidden below the text and which seems to be above the text are deleted:
For a comparison here's a version with texts extruded in the 3D program:
They have right perspective, but their visibility is not perfect because the used program doesn't allow adjusting the lights. Actually there's no lights. No ray tracing is done, the drawing is shaded with fast algorithms. That makes the light inconsistent, it seems to come from different directions to different surfaces. I guess Blender or other photorealistic 3D software users would get a good laugh if they saw this.
But working in 3D has more advantages than the automatic right perspective:
- works also on curved surfaces
- intrusion is possible
- rounded corners and rounded joint between the logo and the shape body is possible
- advanced 3D programs know realistic looking surface textures and materials, even transparent ones.