Yes, you can! These are called Rapid Battles and they're timed battles you can have with your friends. However, you can't battle your friends' Pokemon. This is more a multiplayer feature where you can battle strong Pokemon at gyms.