For a fixed viewpoint, you can use BoundaryDiscretizeRegion with the option MeshCellStyle to style individual line primitives:
pyramid = Pyramid[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {0, 0, 2}}];
Show[BoundaryDiscretizeRegion[pyramid ,
MaxCellMeasure -> Infinity,
PlotTheme -> "Lines",
MeshCellStyle -> {{1, 4|5|8} -> Directive[Black, Dashing[Large]], {1, _} -> Black},
MeshCellLabel -> MapThread[{0, #} -> Placed[Style[#2, 16, Bold], #3] &,
{Range @ 5, {"C", "D", " B", "A ", "S"}, {Below, Below, After, Before, Above}}],
ViewPoint -> {.1, -3, 1}]] /. {_Line} :> {}

Update:
We can use a slight modification of the function DashedGraphics3D from this answer by Silvia to get a 2D image of Graphics3D object with lines behind the front surface rendered as dashed lines. The only changes I made in the function are to add Pyramid in the list of 3D primitives,
face3DPrimitives = {Pyramid, Cuboid, Cone, Cylinder, Sphere, Tube,
BSplineSurface}
and replace Dashed with Dashing[Large]:
Examples:
SeedRandom[7]
Grid[Transpose @ Table[
{Graphics3D[{FaceForm[Directive[Opacity@.5, LightBlue]],
EdgeForm[Thick], pyramid},
Boxed -> False, ViewPoint -> v,
ImageSize -> 400, SphericalRegion -> True,
PlotLabel -> PromptForm[Style["view point", 16], Style[v, 16]]],
Show[DashedGraphics3D[Graphics3D[pyramid, Boxed -> False],
ViewPoint -> v, ImagePadding -> 120], ImageSize -> 300]},
{v, Round[ RandomReal[{-2, 3}, {4, 3}], .01]}],
Spacings -> {1, 1}]

ViewPoint -> {8, 3, 7}? – cvgmt Oct 14 '21 at 13:344|5|8manually with appropriate list of indices for each spec forViewPoint. ForViewPoint -> {8, 3, 7}the pattern1|3|5works. (You can use the optionMeshCellLabel -> Join[Thread[ Thread[{0, Range[5]}] -> (Style[#, Bold, 16] & /@ {"C", "D", "B", "A", "S"})], {{1, All} -> "Index"}]to see the indices of line primitives.) – kglr Oct 14 '21 at 13:43SeedRandom[7] Grid[Transpose @ Table[ {Graphics3D[{FaceForm[Directive[Opacity@.5, LightBlue]], EdgeForm[Thick], pyramid}, Boxed -> False, ViewPoint -> v, ImageSize -> 400, SphericalRegion -> True, PlotLabel -> PromptForm[Style["view point", 16], Style[v, 16]]], Show[DashedGraphics3D[Graphics3D[pyramid, Boxed -> False], ViewPoint -> v, ImagePadding -> 120], ImageSize -> 300]}, {v, Round[ RandomReal[{-2, 3}, {4, 3}], .01]}], Spacings -> {1, 1}]– John Paul Peter Oct 14 '21 at 23:57DashedGraphics3Dcode ( that is,is replaceface3DPrimitives = { Cuboid, Cone, Cylinder, Sphere, Tube, BSplineSurface}withface3DPrimitives = {Pyramid, Cuboid, Cone, Cylinder, Sphere, Tube, BSplineSurface})? – kglr Oct 15 '21 at 00:04