Yes. You can, as long as you have the appropriate rating and are the sole manipulator of controls. From a FAA response to a similar question:
... a private pilot may log pilot-in-command time, in a complex or high performance airplane, for those portions of the flight when he or she is
the sole manipulator of the controls because the aircraft being operated is single-engine land and the private pilot holds a single-engine land rating.
... 14 CFR section 61.31 requires a person to have an endorsement from an authorized instructor before he or she may act as pilot in command of certain aircraft (a complex airplane, a high performance airplane, a pressurized airplane capable of operating at high altitudes, or a tailwheel airplane). These endorsements are not required to log pilot-in-command time under 14 CFR
section 61.51(e). (emphasis mine)
Excerpt from §61.51 Pilot logbooks:
(e) Logging pilot-in-command flight time.
(1) A sport, recreational, private, commercial, or airline transport pilot may log pilot in command flight time for flights-
(iv) When the pilot performs the duties of pilot in command while under the supervision of a qualified pilot in command provided—
(A) The pilot performing the duties of pilot in command holds a commercial or airline transport pilot certificate and aircraft rating that is appropriate to the category and class of aircraft being flown, if a class rating is appropriate