If you're not using index buffers, you can just use vertex_index / 3 for triangle_index, assuming you're drawing triangles of course.
This won't work if you are using index buffers though, as vertex_index is the vertex buffer index, but you could potentially use a 'flat varying' along with an int vertex attribute.
This is done in webgpu using the 'interpolate flat' attribute, and it works by using the 3rd (or maybe 1st, don't think it's docced) vertex attribute of each triangle as a 'constant' attribute, ie: shader doesn't interpolate between vertices, just uses the 3rd attribute for all vertices.
The only potentially tricky thing is getting the attribute you want to be 'flat' into the last triangle vertex, which can involve rotating order of triangle vertices if you want to keep triangle count low, and sometimes even adding new triangles, but IME very few new triangles need to be added if you do it right and I suspect in the case of a 'correct manifold' mesh none are needed.
I've used this before in gles for flat shading effects and it works well, and I've checked it works in dawn and it appears to although I've never done anything with it in dawn to date. I was considering attaching a 'materialId' to each triangle this way, but didn't get around to trying it. It's still not easy to create a material array in modern shader languages, unless all your textures are the same size so you can use a texture array, which is probably OK for pros but not for hacks like me who scrape all their textures off the internet, although I guess you could preprocess/resize all textures to be the same size? What would be super nice of course would be 'bind group arrays'!