I don't think you can because the same water composition could come from different rock formations. You can try to get an idea of what kind of minerals are equilibrated with your water sample. If your water has too much Ca or Mg you may try to equilibrate it with calcite and/or dolomite and look for precipitation or small dissolution of these minerals (which is an indication that they were in contact with the water when the sampling was done). However, clay minerals will be more difficult to identify because they have more chemical elements.
You cannot assure that your composition in PHREEQC is correct unless you may the mineral composition of the formation and model it in the software. Besides, you have uncertainty limit that tells you how accurate your model is. You can find some information in my publications:
This geochemical package (PHREEQC) and its different libraries have the capability of equilibria calculation that includes aqueous, mineral, gas, solid-solution, surface-complexation, and ion-exchange equilibria; capabilities of speciation and saturation index calculation; batch-reaction and one-dimensional transport; reversible and irreversible reactions; kinetic reaction; mixing solutions; inverse modeling in which the temperature (van’t Hoff expression or an analytical expression is used) and pressure effects are included.
Please note that to the inverse reactions modeling!
For answering your question, you have to look back and recall CEC (cation exchange capacities) or ion exchange definition. Look at chapter 3 of Modern Chemical Enhanced Oil Recovery Theory and Practice by james sheng. Considering that equation, you are able to implement it to the package. Moreover, I do like to suggest you to looking for Soft and hard coupling approaches of simulators: such as UTCHEM and IPHREEQC. For further information you can see this paper: Muller, M., Parkhurst, D., L., and Charlton, S., R. 2011. Programming PHREEQC Calculations with C++ and Python a Comparative Study.