Bernie Sanders' 2016 presidential campaign de facto ended on June 6th, when his opponent, Hillary Clinton, attained enough delegates to secure a majority at the Democratic National Convention, ensuring that she would be confirmed as the party's candidate for the presidency. Sanders met Clinton in person on June 14th to privately concede, and then gave a speech two days later in a live internet broadcast which all but confirmed his concession.
The offer from Jill Stein, who was then the probable presidential candidate for the Green Party, came about three weeks later, and was reported in the Guardian on July 8th, after Sanders had de facto lost the nomination, but before this was set in stone at the DNC. It is unclear exactly when the invitation was made, but Stein says she made it in a private email to Sanders "at the end of the primary season". Although not solely an invitation to run as the presidential candidate, Stein said that "everything is on the table", and that "He could lead the ticket and build a political movement".
As to whether the invitation was too late to allow Sanders to feasibly win, the only issue I can think of on that front would be so-called "sore loser" laws, which as the question points out, bar candidates that fail to secure the nomination of one political party from going on to run as an independent candidate, or as a candidate for another party. Ballotpedia has collated a list of state-level precedents which confirms that these laws do not apply to presidential primaries in all states having such laws, all apart from South Dakota & Texas. In these states, Sanders' would not have been allowed to appear on the ballot paper, and would have had to be a write-in candidate.
Given that it is perfectly possible to win the presidential election without winning Texas & South Dakota, it would still have been possible, if improbable, for Sanders to win the presidency.