LLMs in the Imaginarium: Tool Learning through Simulated Trial and Error