Yes a toilet can be installed in your garage whether it's an attached garage or a detached garage.
I have a detached garage that I installed a toilet in so that if I needed to use the toilet I would not have to run into the house when I'm out working in my garage.
I just had to build a bathroom inside the garage by framing some additional walls and sheet rocked it and I had a toilet and sink inside of it.
I didn't need a permit for it but some places may require a permit to build a bathroom in a garage or to install a toilet in a garage.
It's pretty simple to install a toilet in a garage and all you have to do is break up the concrete, run a sewer line and water line and install the toilet.
A good contractor could do it easily as well.