Sushi-ya, kaiseki, and high-end restaurants often forbid photos. A polite 'shashin daijoubu desu ka?' (is a photo okay?) settles it.
Casual ramen shops, izakaya, and cafes are usually fine. Look for posted signs.
Never photograph other diners. Pointing a camera at people without consent is universally rude.