Shkreli got in trouble for lying to his investors about losses in his hedge fund. He paid them back later, but to the feds that was a little like robbing a bank, then winning the lottery a few years later and deciding to give the bank its money back.
As long as Musk's companies accurately disclose what the money they're raising is going to be used for, I don't think there is any issue. Shkreli was convicted because he claimed to investors that he was going to invest in x but actually invested in y.
Well, the board members of SpaceX, including musk, have a fiduciary responsibility to SpaceX only, when making decisions about what to do with SpaceX money. So investing or loaning money to Tesla or otherwise giving them some kind of sweetheart deal would inevitably open SpaceX up for a lawsuit from SpaceX shareholders.