Use aligning viewport to selected mesh elementsaligning viewport to selected mesh elements (in this case, edge of the pyramid). This is faster than creating custom transform orientation, however you should keep track of viewport angle.
- Select one of pyramid's edges. Set Selection mode to Edge.
- Press Shift+Numpad 3 to enter Side Ortho view for selected edge.
- Enable Snap during transform, set Type of element to snap to Vertex.
- Select vertex to be aligned to the top. Press Alt+Space and select View to set transform orientation to View and to move selection along it.
- Grab vertex while choosing for tranform only X or Y axes. Depending on the view press Y or X twice for that. Hover mouse over vertices of pyramid's edges to align selection to them.
(Addition - if the pyramid doesn't have perpendicular side edges)
- Set transform orientation to Normal. Set Pivot Point to Active Element. With the top vertex still selected, select one more, which was hovered over while aligning in the step 5.
- S to scale based on location of the last selected vertex. Lock normal X axis by pressing Shift+X twice. Hover mouse over top vertex of the side edge of the pyramid which is seen in the middle of the pyramid (in Side Ortho view).
While this method is a bit more complex, it provides exact aligning of the top vertex making all the side edges of the same length; thus no faces will be splitted in the middle of the pyramid and the shading will be better. You can preview the gif for simple case in the version history.
See also How do I align the viewport to a face normal?How do I align the viewport to a face normal?