A promising paradigm of quantum computing for achieving practical quantum advantages is quantum annealing or quantum approximate optimization algorithm, where the classical problems are encoded in Ising interactions. However, it is challenging to build a quantum system that can efficiently map any structured problems. Here, we present a trapped-ion quantum processor that can efficient encode arbitrary Ising models with all-to-all connectivity for up to four spins. We implement the spin-spin interactions by using the coupling of trapped ions to multiple collective motional modes and realize the programmability through phase modulation of the Raman laser beams that are individually addressed on ions. As an example, we realize several Ising models with different interaction connectivities, where the interactions can be ferromagnetic or antiferromagnetic. We confirm the programmed interaction geometry by observing the ground states of the corresponding models through quantum state tomography. Our experimental demonstrations serve as an important basis for realizing practical quantum advantages with trapped ions.