How should I fill in a trench left by replacement of a sewer pipe?
You don't say where you are located, but in the UK, to comply with Building Regulations, it would be typical to both bed the pipe on and backfill immediately around it with pea gravel or single-size stone.

Above that, it would depend what is on top of the trench as to how you'd backfill the rest of the trench.

Under a road, you'd likely use MOT type 1 stone, which is generally specified as being compacted in 150mm layers.

Under a grassed area, you could simply backfill with soil. You don't need to compact it, but be aware that it will settle over time. One way to counter this is to over-fill the trench, so it will (hopefully) settle to finish level with the surrounding area.

(Further assuming you are in the UK, if the work is subject to Building Regulations, the local authority Building Inspector will want to inspect and pass the drain before it is covered up).