Participation in the EU Agency for Railways is open to: "third countries, in particular countries within the scope of the European Neighbourhood Policy, the Enlargement policy countries and EFTA countries which have concluded agreements with the Union under which the countries concerned have adopted and are applying Union law, or equivalent national measures, in the field covered".
The precise wording and whether this would permit for the UK to participate in the first place is probably a case for lawyers (i can see a certain point in the above sentence where the absence of a comma might be crucial...). Participating non-members must contribute to the budget financially and may contribute staff. As the agency is rather small it's also a limited amount - probably around 2.5-3.0 million EUR for the UK. Both the management board of the agency and the EU commission have to sign off on a third country participating. Non-member states also do not get any voting rights within the agency.
Summarizing: there's about zero chance for the UK post-Brexit to participate in the EU Agency for Railways.
The above definition of scope for possible participation includes within Europe all current countries except for:
- Monaco and Vatican, whose rail services are all operated by railway agencies from member countries
- San Marino and Andorra, which do not have railways (currently)
Kosovo was the last to enter the scope through the enlargement policy, in February 2018.
It includes countries outside Europe:
- in Asia: Turkey, Georgia, Azerbaijan, Armenia, Syria, Lebanon, Jordan, Israel and the Palestinian Authority
- in Africa: Egypt, Libya, Tunisia, Algeria, Morocco