This is really a question of sound synthesis, and there's no simple answer. There are a whole bunch of possible approaches--it's an entire field of study. Physical Audio Signal Processing by J.O. Smith is a good starting point, as is The Theory and Technique of Electronic Music by Miller Puckette. For guitar, you might particularly be interested in the Karpus-Strong method. Perhaps you should search for a Python implementation of it. It's a common project for students in music technology programs; I'm sure there are many.