If you have a compact one that fits in a bag, you can bring it fine on most intercity trains (though ideally you'd want to check before with the particular line). In local transit it's mostly frowned upon, especially in denser urban areas and busy lines. But you can usually always find some form of accommodation accessible by bike along the route, wherever you're going.