Every time someone asks any question involving training and “Can I…?” The answer is almost always yes.
You can do whatever the hell you want.
Murica (unless you don’t live here)
But, this is normally a loaded question. It’s usually “Can I get jacked while swimming?” “Can I get faster at running and get stronger in the gym?”.
The answer is typical yes. But, you are choosing to be worse at both.
Both options are fine, but don’t be surprised when training stalls or goes slowly in both.
RULE OF SPECIFICITY
It’s all about trade-offs.