The latest version of Server.app that you can run under Yosemite is 5.0.15. It does not appear you can run Server.app 5.1 under Yosemite since it is not offered as an upgrade option under Yosemite.
Therefore you would appear to have no choice, first upgrade to El Capitan 10.11.4, then upgrade to Server.app 5.1. I strongly suspect that initially it will disable Server.app 5.0.15 after upgrading to El Capitan 10.11.4.
Note: Earlier versions of El Capitan e.g. 10.11 and 10.11.1 could run Server.app 5.0.15.
Back up your servers before hand, do both data exports/backups where appropriate and an entire drive clone, e.g. an Archive of Open Directory, an export of your DNS zones, etc. the free Bender tool might be helpful for this. Bear in mind that historically you cannot mix versions of Server.app between Open Directory Master and Replica servers i.e. they all need to be on the same Server.app version or at least same major version, as in this case the major version for both is 5 you might get away with this. This might however mean first destroying any OD replicas, upgrading them, then upgrading the OD master then re-creating the OD replicas.
Sadly this is just one of several server related areas where Apple is far weaker than Microsoft. At least Apple do not try and bankrupt you. 😉