For example, consider a flight from Los Angeles to Moscow via New York. Is there a limit to the number of tickets that can be bought from either Los Angeles or New York?
In general, no. Each airline manages their tickets and fare pool as they see fit. For example United will manage something "LAX to FRA" as a route with its own set of fare rules. They may route this through EWR, but also through any other suitable United hub (ORD, IAD, SFO, ...) or a codeshare with Lufthansa. That's typically done dynamically, i.e. when you book the ticket, they route you through the "cheapest" hub at the time.
"Cheap" and "empty" are often related. As a a certain flight fills up, the airline typically yanks up the prices, whereas prices will generally stay low, if the flight remains empty. Hence picking the "cheapest" route helps balancing load at the same time.
Your specific example may be different. The only airline that flies between New York and Moscow is Aeroflot and the only LAX->JFK->MOW route is with JetBlue and Aeroflot. These are two loosely affiliated airlines and I don't know how they manage their shared ticket pools. Aeroflot also offers a non-stop to LAX which seems very attractively priced, so that would be the way to go here.
In a generic domestic multi-city flight, operated by a single domestic airline, there is usually no such restriction.
When it comes to international flights or codeshares, then it may become a lot more complex, due to restrictions on the "Freedoms of the Air", associated negotiations, or commercial agreements. There could also be operational reasons.
Consider a flight A-B-C, where B and C are in a single country, but the flight is operated by an airline of the country where A is.
The country where B and C are may allow the internal flight, but may either forbid sales on that segment taken alone (i.e. the airline can sell tickets between A and B, or between A and C, but not between B and C). That one is actually quite frequent (or at least it used to be, not so sure nowadays).
Or it may allow it, but set limits on the number of seats sold that way.
Consider an airline which wants to add more flights between A and B. But the country where B is wants the airline to serve another minor city C, while the airline feels the city is too small to operate a dedicated flight between A and C. They may end up with a deal that allows the airline to add a flight to B, provided they then continue to C.
This may then result in the country setting a limit to the number of passengers stopping in B, or trigger the case below.
The airline may feel there aren't enough people on one of the segments, and not use a full crew (especially if the flight is one very long haul segment followed by a short haul segment). This would then result in a limitation on the number of passengers they can actually carry (there are rules which state you need X crew per Y passengers).
Of course, in that case, if they frequently hit the limit, the airline will adjust its roster and add a full crew!
When multiple airlines codeshare a flight, depending on their agreements and their reservation systems, they may either shared the same pool of seats, or pre-assign a number of seats to each of the codeshare partners. The number of seats for each partner may not be the same on all segments (actually, not all segments are necessarily shared by the same partners). I honestly hope that current reservation systems are not encumbered by such limitations, but as will all legacy systems...