Semantic communications target to reliably convey the semantic meaning of messages. It is different from existing communication systems focusing on reliable bit transmission. To achieve the goal of semantic communications, we propose a signal shaping method by minimizing the semantic loss, which is measured by the pretrained bidirectional encoder representation from transformers (BERT) model. The signal set optimization problem is transformed to a vector optimization subject to a power constraint. We propose an efficient projected gradient descent method to solve the problem and prove its convergence. Simulation results show that the proposed method outperforms existing signal shaping methods in minimizing the semantic loss.