Yes, you can. The process to determine how much and what size wire you need isn't difficult, but there are options depending on your price point and desired efficiency. For my calculations I'm using this chart:
https://www.powerstream.com/Wire_Size.htm
For instance, let's assume you have a 6kW inverter and a 48VDC battery. For ease of computation, the battery will be assumed to be at or above 50V when under full load (6kW draw or 6kW charge).
That means the wire has to conduct 120A. Looking at the chart under "Maximum amps for power transmission" you'll find that 0awg wire is suitable for up to 150A.
On that same line, you'll find that 0 awg wire has a resistance of 0.0983 ohms per 1,000 feet. You will be running 150 feet, however the current has to go there
and back, so your total run is 300 feet. 300 ft * (0.983 ohm/kft/1000) = 0.0295 ohms.
Ohms law, Volt = Amp * Ohm indicates that when you're pulling the full 6kW, or 120A, then the 300 feet of wire will cause a voltage drop of 120v * 0.0295ohm = 3.54V. At 120A, 3.54V is 424W - so you'll lose just over 400W of power to heating the 0 awg cables when you are discharging or charging all 6kW. Over 150 feet, 424w is under 3W per foot, which should pose no problems. This is a 7% loss, and it's linear, so you'll always lose 7% of whatever energy you move along those wires at 50V.
Further, the inverter will see 50v - 3.54v = 46.5v when the batteries are at 50v and the inverter is pulling 120A. When it's charging at 120A it will instead see 53.54v if the batteries are at 50v. Note the difference will affect your charging parameters, and your battery cutoff parameters.
300 feet of 0 awg copper wire is about $5/ft or about $1,500. You'll also need to account for the cost of conduit, digging, etc.
Doing the same calculation for aluminum wire will show that you need 4/0 wire, which has a lower resistance of 0.082ohms/kft, so a reduced 6% loss over 300 feet, and it's $1.90/foot, for a cost of $570. Note the huge price difference for the same carrying capacity - this is why 200A and 400A home service entrance wires area almost always aluminum. You will need to be careful and make sure all your connections are aluminum compatible and use the appropriate anti-oxidant compound. Note also that the larger cable will be more difficult to work with, and may require larger conduit.
For a different size inverter, or a different voltage, the calculations will be different, but this hopefully gives you a recipe to determine what would fit your needs.
Depending on your specific installation, you might want to consider other options to reduce cost or increase efficiency, but this isn't a bad way to go. Also, while it might be tempting to think about installing this heavy duty wire now and re-pupose it later for AC use (for instance, moving all your power equipment to the outbuilding) if you want to do that you'll need 3 lines of equal gauge, and a smaller ground wire. Just laying these two cables and a small ground for DC doesn't mean AC will be trivial later. Adding a third conductor and a suitable ground wire gives you a lot more flexibility in how this run can be used in the future. And unlike batteries, panels, and inverters, this wire will be useful for a lot longer than 20 years, so it's worth some investment and long term planning.