The 41-year-old Salmon Fishing in the Yemen actor will play a criminal in the film, which is due to begin production in Australia early next year.
The film will focus on the complex relationship between McGregor's public enemy number one character and his young protégé, reports Deadline.
Further cast are yet to be announced, but filming locations have been revealed as Perth, Kalgoorlie and Western Australia.
Son of a Gun will be the debut feature from Australian screenwriter Julius Avery, who won the Cannes Jury Prize in 2008 for his short film Jerrycan.
McGregor is currently shooting August: Osage County with Meryl Streep, Benedict Cumberbatch and Julia Roberts, and will next be seen in The Impossible, a film about a tsunami from Spanish director Juan Antonio Bayona that will be released in December.
Ewan McGregor - Career in pictures:
Copyright: Rex Features Gramercy/Everett