Topology optimization of truss structures is a constrained problem in which traditional methods often face high computational cost and slow convergence. This work investigates a Large Language Model (LLM)-based framework for optimizing truss layouts to maximize structural stiffness under prescribed loading conditions. The optimization problem is reformulated as a sequential design process, where truss configurations are assembled step-by-step following predefined grammar rules to ensure structural feasibility. Each design is represented symbolically as a sequence, enabling the application of LLMs. Specifically, a GPT-2 architecture is trained using a mechanically-informed loss function, in which training samples are weighted according to structural stiffness, thereby achieving structural optimization implicitly. This guides the model toward high-performing solutions while preserving diversity in the design space. The approach is assessed on six benchmark problems characterized by varying seed configurations and loading conditions. The generated structures achieve between 82% and 100% of the corresponding global optimum stiffness. In doing so, the model generates novel and mechanically sound topologies not observed during training. Although LLMs were originally developed for natural language processing, these results suggest that their architecture can be leveraged for engineering design, positioning LLM-based generative frameworks as complementary tools for exploring large and complex design spaces in structural optimization.