Nexus 5 Change Resolution/DPI
Well, you can't change the actual screen size or DPI, because those are physical characteristics of the screen hardware.  You can't stretch the phone to be the size of a tablet, or change how the LCD is wired.

On a rooted device, you can edit a configuration file to change how big Android thinks the screen is, which will affect the calculated DPI and the resulting layouts.  That isn't convenient for testing, though, because rendering a "larger" screen's UI on a smaller screen will result in tiny text that's hard to read and tiny touch elements that are hard to interact with.

For testing a variety of screen sizes, you're better off creating a variety of AVDs in the emulator.  That's much simpler and less dangerous than rooting and editing low-level system configuration files just to test a layout.