US car maker and clean energy company Tesla Inc (NASDAQ:TSLA) said on Sunday that it will build a factory in Shanghai that will manufacture its battery energy storage product Megapack.