Allow rotate into portrait mode but do not rotate external display
Try these instructions, using a computer with adb installed and your phone connected:

Android Jelly Bean (4.2) locks HDMI rotation by default. You can unlock by the instruction of this commit.


  
  Add special mirroring modes for demonstration purposes.
  Assume rotation of HDMI display is portrait.

adb shell setprop persist.demo.hdmirotation portrait

  Don't lock rotation while HDMI is plugged in.  

adb shell setprop persist.demo.hdmirotationlock false

  Hide secondary displays from apps but continue mirroring to them.

adb shell setprop persist.demo.singledisplay true

  


Source: https://community.freescale.com/docs/DOC-97740