Usually you only limit this optimisation to a scenario where the material is equal, else you have exactly this problem. The best you can usually do if you want to batch render these in a collapsed mesh fashion is to use texture atlases. Packing more information into the vertices can work if you really want to achieve this for some of the uniform parameters, such as an array of colors of which the correct one is picked by using the index stored in the vertex, but then you still need the same set of shaders etc.
Perhaps it's worth describing what you're looking to get out of it, because even if it were possible to merge them into a single mesh and have multiple materials for that combined mesh, it could still not really reduce the amount of draw calls (which is what the combining of static meshes is often used for)