Of course you can. It is important that the Minecraft and Forge versions of the server you want to enter match your Minecraft and Forge versions. For modpack servers, the corresponding modpack should of course also be installed and activated.