I think tanking in baseball is essentially pointless. First, draft-eligible players are much more difficult to project in baseball than in other sports, Second, my guess is that tanking almost never makes more of a change than 2 or 3 positions in the draft anyway. But if it is felt that tanking needs to be discouraged via a lottery, then setting up the lottery so that a team can not advance or descend by more than 3 positions ought to do it. I don't like that a team with the 7th-best record in its league has any chance, even a remote one, to wind up with the first pick. Nor do I like that a team with the worst record has any chance, even a remote one, to wind up with the 18th pick.
How could this be done? Here's how I would do it. Choose one of the first four teams in the draft order at random to receive the first pick. For deciding the second pick, add team #5 to the remaining three and choose at random. For the third pick, add team #6 to the remaining three and choose. At that point, if team #1 has not yet been chosen, they get pick number 4. Otherwise add #7 and choose the team for the fourth pick. At that point, if team #2 has not been chosen, they get pick #5. Continue in this manner until the first 18 positions are decided. From that point on the selection order stays as it would have been without a lottery.