I think the short answer is that you'd have to design a new mount specifically to achieve this, or use a smaller sensor than the mount would otherwise support (e.g. ASP-C sensor with an EF-only mount; no EF-S).
If you take the lens off a Canon 5D, for example, and look at the mirror/sensor (you can use Bulb mode or the sensor cleaning mode to see it) you'll see there's very little room around the sensor for anything else. The mirror folds up to just above the top of the sensor, and when down it is as far forward as the rear of an EF lens permits.
There's two ways you can go with this...
Allowing a rotating full-frame sensor, would require that there is effectively space for a square sensor (36x36 mm instead of the standard 36x24 mm for full-frame). This would thus also mean having a larger mirror to cover that whole space (and a larger viewfinder), and that the mirror would fold up higher to accommodate the sensor in portrait mode.
Since the mirror must sit at 45º, and needs to fold up to allow the image to be captured., the space between the sensor and the lens flange would need to be increased. The current sensor-flange distance is minimised, allowing just enough space for the existing mirror here, and the lens design relies specifically on focusing light onto the sensor at the standard sensor-flange distance. You can't just change this parameter without extra optics (which would need to fit in that space too!).
In short, allowing a portrait sensor means a larger, higher mirror, and a longer sensor-flange distance than the lens mount was designed for. I guess if you were really keen you could design a mirror that gets out of the way by another mechanism (e.g. flips and slides), but this would be more complex, more prone to failure, and likely much slower.
However... if you want to keep the existing sensor-flange distance, you could limit the size of the sensor accordingly. The height of a full-frame sensor is 24mm, so an APS-C-sized sensor would fit in this space in portrait mode (Nikon ~23.6mm, Canon ~22.2mm).
However, you'd need to keep the same sized mirror as the full-frame camera, and thus could not use lenses that extend further into the body (like Canon's EF-S mount lenses). The pentaprism and viewfinder would also have to be full-sized to accommodate portrait-mode.
In short, you'd be just putting a rotating APS-C sensor in a full-frame camera. Or if you start from an APS-C camera, you'd be dropping the sensor size down to a bit smaller than Four Thirds size (i.e. to max ~15mm width). Either way it seems like you're losing more than you gain.
In a mirror-less camera this might be doable (since you don't have a taller mirror to get in the way), but then that's no longer a DSLR (and it may be cheaper to make square sensors than rotating ones, especially at the smaller size of typical mirrorless sensors).
Finally, an extra complication would be the precise calibration of the sensor-flange distance: a rotating sensor means this could easily vary as it rotates, or more easily get knocked out of alignment so it's not perfectly parallel with the lens mount flange.