The $1-billion unrealized gain on SpaceX holdings provided a notable boost to Tesla’s reported net income for the second quarter.