I want to confirm if one pin can be an input and later when needed can be made an output and high/low as needed?

It's just that when an input, it will have 2.5 volt on it through a voltage divider and then I want to inject 5V into the middle point of the voltage divider by making pin an output and toggling it high.

I am concerned if the pin can be made an output from an input and pushed high, while it already has 2.5v on it continually.