Hi FS,
Sure you can log it, provided only that you are:
(i) legally qualified to command multi-engine airplanes, and
(ii) actually acting as PIC.
In other words, to log PIC the instructor has to be considered just a passenger, and can't log any time him/herself. If you can negotiate that, great, although most instructors are jealous of their desire to log time, and many FBOs will not permit a rental pilot to rent a twin solo or with a passenger.
🙁
While this restrictive approach undoubtedly makes it difficult to acquire PIC time, really it all makes sense. Personally, I have always thought that it is a bit of a fraud to have two people simultaneously logging PIC: simple logic dictates that there can only be one commander at one time.
My rough definition would be: the PIC is the person who will take over in the event of an emergency, and who is ultimately answerable for the conduct and safety of the aircraft's flight. Usually that means the instructor; but just because someone is instructor rated doesn't prohibit them from going along for the ride, without any authority or responsibility (obviously, this must be agreed to prior to the flight, if the instructor-passenger will have access to the aircraft's controls).
Best of luck to you!

You're better off asking these questions than just assuming it can't be done, or making questionable entries in your logbook (that would require a lot of Liquid Paper, if you are subsequently challenged!)
Swingline
P.S. In the U.K., they apparently have a category called "P1 under supervision", which I think is a bit of a
non sequitur, but at least does away with the fiction of two aircraft commanders. See further
this thread.