Subdivide surface based on intersection
Actually I recalled another option called Knife Project.
In Edit mode of the cube remove the top face like this:

In Object mode select cube first and sphere second.

Then go to edit mode. Select all. Make top orthographic view and use Knife project operation from Mesh menu.

Check Cut trough box

Now you can delete your cube and when you go to edit mode with your sphere you can see faces were intersected. So you can select them separately and assign another material.

Hope it helps!