Make the Marinade: In a mixing bowl, combine the soy sauce, 1 tablespoon of sesame oil, and the grated ginger. Using a Microplane or fine grater, grate 1 garlic clove into the mixture. Place the tofu cubes in a shallow dish (such as a baking dish or pie plate) and pour the marinade over them. Toss gently to coat, ensuring the marinade is evenly distributed. Set aside to marinate while you prepare the other ingredients.
Toast the Coconut: Heat a dry skillet (12-inch) over medium heat. Add the coconut flakes and cook, stirring occasionally, until lightly golden and fragrant, about 2–3 minutes. Transfer the toasted coconut to a small bowl and wipe the skillet clean to prepare for the next step.
Cook the Vegetables: Place the skillet back on the stove over high heat and add 2 tablespoons of sesame oil. Once hot, add the onion slices and sauté, stirring occasionally, until softened and slightly translucent, about 7 minutes. Add the squash slices, ½ teaspoon of salt, and the black pepper, and cook until the squash begins to soften and caramelize, about 5–10 minutes. Thinly slice the remaining 3 garlic cloves and stir them into the skillet during the last minute of cooking. Remove the vegetable mixture from the skillet and set it aside in a large bowl.
Brown the Tofu: Add the remaining 1 tablespoon of sesame oil to the skillet and heat over high heat until it’s very hot. Pat the marinated tofu cubes dry with paper towels to remove excess moisture, then place them in the skillet in a single layer. Let the tofu cook undisturbed for 1–2 minutes or until the bottom develops a golden-brown crust. Carefully flip the tofu cubes and brown the other side. If the pan begins to smoke, open a window or turn on your fan, as this step requires high heat.
Combine and Heat Through: Once the tofu is browned, return the cooked vegetable mixture to the skillet. Pour in any remaining marinade from the tofu dish and stir gently to combine. Let the mixture cook for another 1–2 minutes to heat through and allow the flavors to meld.
Finish and Serve: Turn off the heat and toss in the fresh basil leaves, gently mixing until they wilt slightly. Add a squeeze of fresh lime juice and adjust the seasoning with additional salt if needed. Garnish the dish with the toasted coconut flakes and serve immediately.