Short answer, yes you can do it
Long answer .. you may not want to
The battery differnces , even with Identical batteries (assumming fllooded, agm or gel) , based on age ififference s enough to be worrisome, your older ones will try to over charge and your newer ones will be undercharged. At some point you will rediuce the efficeincy and longevity of the entire bank.
Now.. with different capacity batterires and an age diference ... hmmm , without some mighty fine electronics in betwen to adjust charge/discharge rates (probably more costly than the battery) ...ok... but really not feasible