There can be small cube planets or asteroids, but as they get bigger, the gravitational force compresses them to a sphere. But what is the maximum size?
It depends what you consider a cube or a sphere. Is the Earth a sphere or do the mountains make it something else?
As you do seem to understand more massive planets have more gravity, which shapes them into a sphere. This is because matter on the outside of the planet is attracted to the center. On Earth a loose rock is more likely to fall from the top of a mountain down a valley rather than the other way around, and the Earth becomes more of a sphere with the rock at the bottom. This process does not happen as much with asteroids which have less mass hence less gravity. This is why asteroids can have funny shapes. So there is no perfect cube or sphere planet or asteroid, but the more mass the higher the chances to look like a sphere. The exact answer to your question would depend on what you are ready to accept as a cube.
Let's not stop there and imagine you defined your requirements for an asteroid that looks enough like a cube. It is theoretically possible for asteroids the size of the moon to maintain a cube-like shape without collapsing on themselves. However asteroids are shaped by random factors (collisions with other bodies, etc.) and the chances of such structures occurring naturally decrease with their mass. So I hope a satisfying answer to your question is "Really large asteroids that look like cubes are theoretically possible but the likelihood of encountering one decreases with its mass".