A key challenge in integrated sensing and communications (ISAC) is the synthesis of waveforms that can modulate communication messages and achieve good sensing performance simultaneously. In ISAC systems, standard communication waveforms can be adapted for sensing, as the sensing receiver (co-located with the transmitter) has knowledge of the communication message and consequently the waveform. However, the randomness of communications may result in waveforms that have high sidelobes masking weak targets. Thus, it is desirable to refine communication waveforms to improve the sensing performance by reducing the integrated sidelobe levels (ISL). This is similar to the peak-to-average power ratio (PAPR) mitigation in orthogonal frequency division multiplexing (OFDM), in which the OFDM-modulated waveform needs to be refined to reduce the PAPR. In this paper, inspired by PAPR reduction algorithms in OFDM, we employ trellis shaping in OFDM-based ISAC systems to refine waveforms for specific sensing metrics using convolutional codes and Viterbi decoding. In such a scheme, the communication data is encoded and then mapped to the signaling constellation in different subcarriers, such that the time-domain sidelobes are reduced. An interesting observation is that sidelobe reduction in OFDM-based ISAC is dual to PAPR reduction in OFDM, thereby sharing a similar signaling structure. Numerical simulations and hardware software defined radio USRP experiments are carried out to demonstrate the effectiveness of the proposed trellis shaping approach.