If you want to take your bike onboard a train, you should always check with the rail company before boarding with your bicycle. In general, you are allowed to take your bicycle onto most trains, provided your bicycle is easy to handle and does not obstruct other passenger's ability to travel. Some railway companies will charge a fee for bringing your bike onboard, which means you'd have to purchase a separate ticket for your bike. If your bike is foldable, though, train companies will generally consider it as a regular piece of luggage (meaning no additional tickets would be required).
Note that some trains, especially high-speed trains, may be more restrictive when it comes to taking bicycles onboard its service. In addition, train companies can refuse you from boarding in case the trains are too full, as your bicycle would take up too much space in that case.
When using the DiscoverEU App to plan your trip, you can add the filter ‘Bike carriage’ to show only trains that allow bicycles on-board (in the “Planner” and “Stations” sections).