Measure the distance between your ceiling joists and record the measurements.
Lay a foam panel down on the floor and cut it to the width you've measured, using a utility knife to score the panel and then breaking the panel along the line with your hands.
Place a step ladder at one end of the ceiling. Apply construction adhesive to one side of the panel. Lift the panel up and place it against the ceiling, pushing it against the rim joist at the end. Hold the panel until the adhesive sets enough to hold the panel in place.
Cut your next panel and butt it against the end of the first panel. Continue until the length of the ceiling has been covered. Move to the next set of joists and apply more panels using the same techniques. Continue until the ceiling has been covered.