Yes, it is absolutely okay and very much appreciated for foreigners to bow in Japan. While the Japanese do not expect visitors to master the complex "degrees" of bowing (like the formal 45-degree saikeirei), a small, respectful nod of the head or a slight 15-degree bend at the waist goes a long way in showing politeness. It is a universal sign of "thank you," "hello," or "excuse me." Foreigners often make the mistake of bowing while simultaneously shaking hands or "praying" with their hands together at their chest (which is a Thai tradition, not Japanese). To bow correctly, keep your back straight, look down slightly, and keep your hands at your sides (for men) or folded in front (for women). Japanese people are generally very forgiving of "gaijin" (foreigner) etiquette errors and will often reciprocate with a bow of their own. The most important thing is the intent of respect; even if your bow isn't technically perfect, the effort is viewed as a sign of cultural sensitivity that will be warmly received by locals in shops, restaurants, and hotels.