Welcome to StackExchange! First, you should know how to set vertex colors to meshes, this answer explains that in details. Next, note that the mesh resulted from joining all source objects has its vertices ordered such that the first n vertices are those of the first source object, the second n vertices are those of the second source object and so on where n is the number of vertices of the source object. So if we color every n vertices the same color, we will be fully covering each object with the same color.
Let's say we have a list of colors "Colors" where each color represents the color of an object, then we can repeat each color n times using this expression:
[color for color in Colors for _ in range(n)]
If we now set the outputs colors of the above expression to the mesh, we get what we want. But how do we know n (the number of loops)? All we have to do is sum the amount of vertices per polygon using a simple loop. So the full node tree becomes:
Where the script is from the answer I linked. This will produce: