Working for one professor, want to write paper with another party
Ask your professor if it is okay with him.

During my PhD it was never a problem to work with other PhD's, it was actually well received and encouraged. Even collaborations that go beyond the professor's own group. Of course your own work should have priority, but spending some of your time on other projects has not been problematic.