I wanted to connect a Real Time Clock DS3231 to Atmega pins 27 (SDA) and 28 (SCL).
I would think I would not be able to do that if using these pins for outputs to HC154.
Correct. It's a design flaw in the peggy2 board. The are lots of other pins they could have used which don't also have special functions. On the other hand, even if you avoid using A4/A5, how are you going to connect the rtc to them? Soldering wires to the chip pins is not recommended. Unless you are an expert solderer, the heat can damage the chip. Perhaps you can solder fine wires to the socket pins on the rear of the board.