You didn’t mention your dog’s age but to get control of the situation you will have to assert yourself as pack leader. Start by housebreaking your dog, which means training it to pee outside only. If the dog does something right, immediately reward with a treat and praise. If the dog does something wrong, immediately say a very firm “No!” Make the dog understand that its behaviour was wrong. A dog shows understanding of wrong-doing by taking a submissive stance. It may look away, lower its head and tail, a lot like humans when they are accused of wrong-doing.
Then show your dog what you want it to do. For example, if you stop it from peeing in midstream, quickly take it outside and patiently wait for it to calm down and finish its business.
Cesar’s Way may have more answers for you.