It is maybe less an algorithm than a substitution model you are looking for. This review may be relevant. Just pick a suitable substitution model. The choice depends on under which selection pressure you assume your sequence is. A codon model can be used for protein coding sequences and a DNA model for non-coding sequences, then mutate each given position or codon based on the substitution probabilities given in the matrix in each generation and run this for a number of generations. Possibly, there is an implementation of such a process but I don't know any right now.