Can you wear shorts in a temple or shrine in Japan? What about a short-sleeved T-shirt? Funny socks? Are there any other rules?
Most Japanese have a relaxed attitude towards religion, so there are not many strict rules.
Here are a few pointers to Japanese temple manners:
Don't be noisy and keep a respectful attitude - as you would in a museum. But you don't have to start whispering! Not all Japanese keep to this rule, though, you will see Japanese tourists who can be quite boisterous, not to speak of all the chattering school tours filing through major temples.
You usually have to take off your shoes when entering a temple hall and either leave them outside or carry them with you in a plastic bag. This is not for religious reasons, but for the very practical reason that temples have wooden floors and these would be damaged by all those tourists tramping through on heavy boots... The same rules exists in other wooden buildings, as Nijo Castle.
No other clothing rules - shorts and short skirts are OK. So are T-shirts etc. No color rules either, also your socks can have all the colors of the rainbow (and bare feet are in order as well)! You also can wear a cap or hat, but it is polite to take it off when paying your respects inside the main temple hall.
No photography inside temple halls - this rule is always clearly indicated on signs and very strictly reinforced (for example, in Sanjusangendo in Kyoto). I think it is more about image rights than about religion, though... Outside, in the gardens etc usually photography is O.K. although tripods are normally forbidden (for the same "image rights" reason a few famous gardens as Samboin in Daigoji, Kyoto, forbid all photography). It is polite not to aggressively take pictures of people praying, etc., but again, in Japan you won't find an angry mob against you if you transgress. P.S. A temple where you can take photos inside, even of the Buddhist images, is Todaiji in Nara.
Taking part in religious rituals at temples or shrines or not is totally up to you! You can just go and visit as you would any place of cultural significance, or if you prefer you can take part in small rituals as: ritually washing hands at the basin at the entrance to a shrine, clapping hands and bowing at the main hall of a shrine, lighting candles and/or incense in a temple. and saying a silent prayer in both. You don't have to be a Buddhist or Shintoist in order to take part in this, in Japan religion is more about daily practice and ritual than about belief. And, if you don't want to take part, that is perfectly O.K. as well!
A visit to a temple or shrine in Japan can be a very relaxing experience!